[PR #124] [MERGED] Various updates to PregelNode and Pregel classes. Update validate.ts to match Python implementation. #505

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraphjs/pull/124
Author: @andrewnguonly
Created: 4/30/2024
Status: Merged
Merged: 4/30/2024
Merged by: @andrewnguonly

Base: mainHead: migrate-pregel-2


📝 Commits (10+)

  • 80c2e9f Implement Pregel types and update debug print methods.
  • 4aa4d54 Merge branch 'main' into migrate-pregel
  • 34b5251 Rename ChannelInvoke to PregelNode. Remove field. Update constructor arguments.
  • 61fe2dd Change type of PregelNodes.channels back to support string instead of string[].
  • a53ceed Update ChannelRead class.
  • c25077a Update ChannelWrite.
  • 6dea09e Update PregelNode pipe() function.
  • 229b40e Update mapInput() and readChannels() in io.ts.
  • 8532bf8 Add mapOutputValues() and mapOutputUpdates() to io.ts.
  • 4381301 Fix lint error.

📊 Changes

10 files changed (+777 additions, -318 deletions)

View changed files

📝 langgraph/src/constants.ts (+2 -0)
📝 langgraph/src/graph/graph.ts (+7 -8)
📝 langgraph/src/graph/state.ts (+5 -8)
📝 langgraph/src/pregel/index.ts (+131 -104)
📝 langgraph/src/pregel/read.ts (+44 -2)
langgraph/src/pregel/reserved.ts (+0 -3)
📝 langgraph/src/pregel/validate.ts (+64 -62)
langgraph/src/tests/pregel.read.test.ts (+124 -0)
📝 langgraph/src/tests/pregel.test.ts (+196 -131)
langgraph/src/tests/pregel.validate.test.ts (+204 -0)

📄 Description

Summary

This PR includes various updates to the PregelNode and Pregel classes. They're smaller, isolated changes with the goal of reducing the number lines changed in future PRs that will include more business logic changes. For example, some of these changes are non-functional (e.g. renaming variables).

Additionally, the validate.ts file is updated to match the Python implementation.

Implementation

  1. Pregel changes:
    a. Update the class interface to match the Python implementation. For example, adding streamMode and removing hidden.
    b. Rename fields. For example, input --> inputChannels.
    c. Create standalone validate() method. Call it in constructor.
  2. Update implementation of Channel.writeTo().
  3. PregelNode changes:
    a. Implement getWriters() and getNode() functions.
    b. Change channels from Record<string, string> | string to support array, string[]. This change has propagating changes in other files.
  4. Update validate.ts to match the Python implementation.
  5. Removed reserved channels functionality (i.e. reserved.ts).

Next Steps

  1. Migrate Pregel._prepareNextTasks().
  2. Migrate Pregel.stream() and Pregel.invoke(). This will be the bulk of business logic changes.
  3. Apply changes from this PR: https://github.com/langchain-ai/langgraph/pull/366
  4. Apply changes from this PR: https://github.com/langchain-ai/langgraph/pull/367

Notes

  1. I'm not sure why the commit history includes a bunch of extra commits. I think it's because I branched off a branch and not main.

🔄 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/124 **Author:** [@andrewnguonly](https://github.com/andrewnguonly) **Created:** 4/30/2024 **Status:** ✅ Merged **Merged:** 4/30/2024 **Merged by:** [@andrewnguonly](https://github.com/andrewnguonly) **Base:** `main` ← **Head:** `migrate-pregel-2` --- ### 📝 Commits (10+) - [`80c2e9f`](https://github.com/langchain-ai/langgraphjs/commit/80c2e9ff13d57aa05a284bc5edda3cfbe12480b6) Implement Pregel types and update debug print methods. - [`4aa4d54`](https://github.com/langchain-ai/langgraphjs/commit/4aa4d5426a8ad4fc67e89a1ebd8bae4b93f42580) Merge branch 'main' into migrate-pregel - [`34b5251`](https://github.com/langchain-ai/langgraphjs/commit/34b525160509dc6da48e1ff1f13425e3c72c6843) Rename ChannelInvoke to PregelNode. Remove field. Update constructor arguments. - [`61fe2dd`](https://github.com/langchain-ai/langgraphjs/commit/61fe2dd3dec83469503241d961de1ca21c8774d2) Change type of PregelNodes.channels back to support string instead of string[]. - [`a53ceed`](https://github.com/langchain-ai/langgraphjs/commit/a53ceed45348cc5f47999dc27ca71dfc2080dd3e) Update ChannelRead class. - [`c25077a`](https://github.com/langchain-ai/langgraphjs/commit/c25077a0a80d19255c683c655ae328401f0d2b6d) Update ChannelWrite. - [`6dea09e`](https://github.com/langchain-ai/langgraphjs/commit/6dea09e0bc8137b1826f2e94215cf3a716038e15) Update PregelNode pipe() function. - [`229b40e`](https://github.com/langchain-ai/langgraphjs/commit/229b40ef84dd17b5b1fc483b59510a84b6086081) Update mapInput() and readChannels() in io.ts. - [`8532bf8`](https://github.com/langchain-ai/langgraphjs/commit/8532bf8e0977f0cc1645d55aa67b0d0d99c5f47d) Add mapOutputValues() and mapOutputUpdates() to io.ts. - [`4381301`](https://github.com/langchain-ai/langgraphjs/commit/43813013ad686373e32497db986ffe5ce9a8e6f0) Fix lint error. ### 📊 Changes **10 files changed** (+777 additions, -318 deletions) <details> <summary>View changed files</summary> 📝 `langgraph/src/constants.ts` (+2 -0) 📝 `langgraph/src/graph/graph.ts` (+7 -8) 📝 `langgraph/src/graph/state.ts` (+5 -8) 📝 `langgraph/src/pregel/index.ts` (+131 -104) 📝 `langgraph/src/pregel/read.ts` (+44 -2) ➖ `langgraph/src/pregel/reserved.ts` (+0 -3) 📝 `langgraph/src/pregel/validate.ts` (+64 -62) ➕ `langgraph/src/tests/pregel.read.test.ts` (+124 -0) 📝 `langgraph/src/tests/pregel.test.ts` (+196 -131) ➕ `langgraph/src/tests/pregel.validate.test.ts` (+204 -0) </details> ### 📄 Description ### Summary This PR includes various updates to the `PregelNode` and `Pregel` classes. They're smaller, isolated changes with the goal of reducing the number lines changed in future PRs that will include more business logic changes. For example, some of these changes are non-functional (e.g. renaming variables). Additionally, the `validate.ts` file is updated to match the Python implementation. ### Implementation 1. `Pregel` changes: a. Update the class interface to match the Python implementation. For example, adding `streamMode` and removing `hidden`. b. Rename fields. For example, `input` --> `inputChannels`. c. Create standalone `validate()` method. Call it in constructor. 2. Update implementation of `Channel.writeTo()`. 3. `PregelNode` changes: a. Implement `getWriters()` and `getNode()` functions. b. Change `channels` from `Record<string, string> | string` to support array, `string[]`. This change has propagating changes in other files. 4. Update `validate.ts` to match the Python implementation. 5. Removed reserved channels functionality (i.e. `reserved.ts`). ### Next Steps 1. Migrate `Pregel._prepareNextTasks()`. 3. Migrate `Pregel.stream()` and `Pregel.invoke()`. This will be the bulk of business logic changes. 4. Apply changes from this PR: https://github.com/langchain-ai/langgraph/pull/366 5. Apply changes from this PR: https://github.com/langchain-ai/langgraph/pull/367 ### Notes 1. I'm not sure why the commit history includes a bunch of extra commits. I think it's because I branched off a branch and not `main`. --- <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:12 -05:00
yindo closed this issue 2026-02-15 18:17:12 -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#505