[PR #125] [MERGED] Update static functions in pregel/index.ts to match corresponding Python implementation #506

Closed
opened 2026-02-15 18:17:13 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraphjs/pull/125
Author: @andrewnguonly
Created: 5/1/2024
Status: Merged
Merged: 5/2/2024
Merged by: @andrewnguonly

Base: mainHead: migrate-pregel-3


📝 Commits (10+)

  • a4cc122 Implement _shouldInterrupt().
  • 3f8bced Update _applyWrites(). Update checkpoint channel versions to max version + 1.
  • aac79f2 Remove _applyWritesFromView().
  • 7b12b48 Update _prepareNextTasks() to support returning Array.
  • 50f5bc9 Update implementation of _prepareNextTasks() to match Python implementation.
  • ef3f381 Remove side effect from _prepareNextTasks() and migrate clients. Add unit test for _prepareNextTasks().
  • 277117a Update implementation of _prepareTasks() and PregelNode.pipe() simultaneously. These changes need to be made together.
  • 18a288e Implement _localRead().
  • 01d73ee Migrate ChannelRead and ChannelWrite to extend from RunnableCallable.
  • 0452396 Update @langchain/core in order to use mergeConfigs().

📊 Changes

9 files changed (+729 additions, -110 deletions)

View changed files

📝 langgraph/package.json (+1 -1)
📝 langgraph/src/channels/base.ts (+3 -3)
📝 langgraph/src/pregel/index.ts (+207 -86)
📝 langgraph/src/pregel/read.ts (+7 -6)
📝 langgraph/src/pregel/write.ts (+2 -2)
📝 langgraph/src/tests/pregel.test.ts (+482 -2)
📝 langgraph/src/utils.ts (+11 -4)
📝 package.json (+1 -1)
📝 yarn.lock (+15 -5)

📄 Description

Summary

This PR updates static functions in pregel/index.ts to the match the corresponding Python implementation. These functions are used in the core stream() and invoke() methods of the Pregel class.

Implementation

  1. Implement _shouldInterrupt() (currently unused).
  2. Update _applyWrites() to match Python implementation.
  3. Remove _applyWritesFromView(). Removing the function did not break any tests. Not sure if this needs to be migrated.
  4. Update _prepareNextTasks() to match Python implementation. Note: The side effect from this function is removed and the calling code is updated to ensure that all existing tests pass.
  5. Implement _localRead() (replaced old implementation of read).
  6. Update ChannelRead and ChannelWrite to extend from RunnableCallable (this was a regression).
  7. Update @langchain/core and update RunnableCallable.invoke() to call mergeConfigs() (this was a regression).
  8. Implement streamChannelsList getter.

Next Steps

  1. Update _default(), stream(), and invoke() in Pregel class.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langgraphjs/pull/125 **Author:** [@andrewnguonly](https://github.com/andrewnguonly) **Created:** 5/1/2024 **Status:** ✅ Merged **Merged:** 5/2/2024 **Merged by:** [@andrewnguonly](https://github.com/andrewnguonly) **Base:** `main` ← **Head:** `migrate-pregel-3` --- ### 📝 Commits (10+) - [`a4cc122`](https://github.com/langchain-ai/langgraphjs/commit/a4cc122773285b122f294d0901dacd2b7c7ef62b) Implement _shouldInterrupt(). - [`3f8bced`](https://github.com/langchain-ai/langgraphjs/commit/3f8bced040873965f3d33a3740974725e6048419) Update _applyWrites(). Update checkpoint channel versions to max version + 1. - [`aac79f2`](https://github.com/langchain-ai/langgraphjs/commit/aac79f2c5cdb686bfeb3f012b106ae96ab59722d) Remove _applyWritesFromView(). - [`7b12b48`](https://github.com/langchain-ai/langgraphjs/commit/7b12b484ef4355af51d01f16db40574bf5cd7a6f) Update _prepareNextTasks() to support returning Array<PregelTaskDescription>. - [`50f5bc9`](https://github.com/langchain-ai/langgraphjs/commit/50f5bc980c49aa1a97988a67126f5d053dbc367d) Update implementation of _prepareNextTasks() to match Python implementation. - [`ef3f381`](https://github.com/langchain-ai/langgraphjs/commit/ef3f381d6d50211f0eaa511cfc72403852cf30e8) Remove side effect from _prepareNextTasks() and migrate clients. Add unit test for _prepareNextTasks(). - [`277117a`](https://github.com/langchain-ai/langgraphjs/commit/277117a58dcc11be1578f250bb961f51693f743c) Update implementation of _prepareTasks() and PregelNode.pipe() simultaneously. These changes need to be made together. - [`18a288e`](https://github.com/langchain-ai/langgraphjs/commit/18a288ebac9329f588243b7b9666945ba1cec4ec) Implement _localRead(). - [`01d73ee`](https://github.com/langchain-ai/langgraphjs/commit/01d73ee8fbfe39f7c27f0d55016709e91da68536) Migrate ChannelRead and ChannelWrite to extend from RunnableCallable. - [`0452396`](https://github.com/langchain-ai/langgraphjs/commit/04523961bb810ce5cd9fe8db64516bfee2e4be52) Update @langchain/core in order to use mergeConfigs(). ### 📊 Changes **9 files changed** (+729 additions, -110 deletions) <details> <summary>View changed files</summary> 📝 `langgraph/package.json` (+1 -1) 📝 `langgraph/src/channels/base.ts` (+3 -3) 📝 `langgraph/src/pregel/index.ts` (+207 -86) 📝 `langgraph/src/pregel/read.ts` (+7 -6) 📝 `langgraph/src/pregel/write.ts` (+2 -2) 📝 `langgraph/src/tests/pregel.test.ts` (+482 -2) 📝 `langgraph/src/utils.ts` (+11 -4) 📝 `package.json` (+1 -1) 📝 `yarn.lock` (+15 -5) </details> ### 📄 Description ### Summary This PR updates static functions in `pregel/index.ts` to the match the corresponding Python implementation. These functions are used in the core `stream()` and `invoke()` methods of the `Pregel` class. ### Implementation 1. Implement `_shouldInterrupt()` (currently unused). 2. Update `_applyWrites()` to match Python implementation. 3. Remove `_applyWritesFromView()`. Removing the function did not break any tests. Not sure if this needs to be migrated. 4. Update `_prepareNextTasks()` to match Python implementation. Note: The side effect from this function is removed and the calling code is updated to ensure that all existing tests pass. 5. Implement `_localRead()` (replaced old implementation of `read`). 6. Update `ChannelRead` and `ChannelWrite` to extend from `RunnableCallable` (this was a regression). 7. Update `@langchain/core` and update `RunnableCallable.invoke()` to call `mergeConfigs()` (this was a regression). 8. Implement `streamChannelsList` getter. ### Next Steps 1. Update `_default()`, `stream()`, and `invoke()` in `Pregel` class. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 18:17:13 -05:00
yindo closed this issue 2026-02-15 18:17:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#506