[PR #120] [MERGED] Update Pregel files to match Python implementation: debug.ts, io.ts, read.ts, types.ts, write.ts #504

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/120
Author: @andrewnguonly
Created: 4/24/2024
Status: Merged
Merged: 4/30/2024
Merged by: @nfcampos

Base: mainHead: migrate-pregel


📝 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

14 files changed (+909 additions, -146 deletions)

View changed files

📝 langgraph/src/constants.ts (+2 -0)
📝 langgraph/src/graph/graph.ts (+2 -2)
📝 langgraph/src/graph/state.ts (+16 -12)
📝 langgraph/src/pregel/debug.ts (+5 -6)
📝 langgraph/src/pregel/index.ts (+25 -47)
📝 langgraph/src/pregel/io.ts (+131 -11)
📝 langgraph/src/pregel/read.ts (+81 -29)
langgraph/src/pregel/types.ts (+38 -0)
📝 langgraph/src/pregel/validate.ts (+3 -3)
📝 langgraph/src/pregel/write.ts (+50 -34)
langgraph/src/tests/pregel.io.test.ts (+371 -0)
📝 langgraph/src/tests/pregel.test.ts (+74 -2)
langgraph/src/tests/pregel.write.test.ts (+48 -0)
langgraph/src/utils.ts (+63 -0)

📄 Description

Summary

The following files are updated (as much as possible) to match the corresponding Python implementation: debug.ts, io.ts, read.ts, types.ts, write.ts. The goal is to update the files without breaking existing tests or adding new functionality that would require significant changes to the Pregel class.

The implementation does not match exactly 1:1 with the Python implementation. I'll leave comments directly in the PR to note any differences.

Implementation

  1. debug.ts: Small updates.
  2. io.ts: Moved readChannel() function to this file. Added the following unused functions readChannels(), mapOutputValues(), and mapOutputUpdates().
  3. read.ts: Renamed ChannelInvoke to PregelNode. Added more fields to PregelNode. Remove PregelNode.when. Update PregelNode.pipe() to support checking ChannelWrite.
  4. types.ts: New file created to match Python implementation.
  5. write.ts: Add ChannelWrite.isWriter() and ChannelWrite.registerWriter().
  6. Add RunnableCallable class as part of fixing bug in https://github.com/langchain-ai/langgraph/pull/345. I haven't migrated all instances of RunnableLambda to RunnableCallable yet. Will do this in a subsequent PR.

To Do

Next Steps

  1. Update pregel/index.ts (Pregel and Channel classes).
  2. Migrate RunnableLambda to RunnableCallable.
  3. Update pregel/validate.ts (I think).

🔄 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/120 **Author:** [@andrewnguonly](https://github.com/andrewnguonly) **Created:** 4/24/2024 **Status:** ✅ Merged **Merged:** 4/30/2024 **Merged by:** [@nfcampos](https://github.com/nfcampos) **Base:** `main` ← **Head:** `migrate-pregel` --- ### 📝 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 **14 files changed** (+909 additions, -146 deletions) <details> <summary>View changed files</summary> 📝 `langgraph/src/constants.ts` (+2 -0) 📝 `langgraph/src/graph/graph.ts` (+2 -2) 📝 `langgraph/src/graph/state.ts` (+16 -12) 📝 `langgraph/src/pregel/debug.ts` (+5 -6) 📝 `langgraph/src/pregel/index.ts` (+25 -47) 📝 `langgraph/src/pregel/io.ts` (+131 -11) 📝 `langgraph/src/pregel/read.ts` (+81 -29) ➕ `langgraph/src/pregel/types.ts` (+38 -0) 📝 `langgraph/src/pregel/validate.ts` (+3 -3) 📝 `langgraph/src/pregel/write.ts` (+50 -34) ➕ `langgraph/src/tests/pregel.io.test.ts` (+371 -0) 📝 `langgraph/src/tests/pregel.test.ts` (+74 -2) ➕ `langgraph/src/tests/pregel.write.test.ts` (+48 -0) ➕ `langgraph/src/utils.ts` (+63 -0) </details> ### 📄 Description ### Summary The following files are updated (as much as possible) to match the corresponding Python implementation: `debug.ts`, `io.ts`, `read.ts`, `types.ts`, `write.ts`. The goal is to update the files without breaking existing tests or adding new functionality that would require significant changes to the `Pregel` class. The implementation does not match exactly 1:1 with the Python implementation. I'll leave comments directly in the PR to note any differences. ### Implementation 1. `debug.ts`: Small updates. 2. `io.ts`: Moved `readChannel()` function to this file. Added the following unused functions `readChannels()`, `mapOutputValues()`, and `mapOutputUpdates()`. 3. `read.ts`: Renamed `ChannelInvoke` to `PregelNode`. Added more fields to `PregelNode`. Remove `PregelNode.when`. Update `PregelNode.pipe()` to support checking `ChannelWrite`. 4. `types.ts`: New file created to match Python implementation. 5. `write.ts`: Add `ChannelWrite.isWriter()` and `ChannelWrite.registerWriter()`. 6. Add `RunnableCallable` class as part of fixing bug in https://github.com/langchain-ai/langgraph/pull/345. I haven't migrated all instances of `RunnableLambda` to `RunnableCallable` yet. Will do this in a subsequent PR. ### To Do - [x] Clean up the code. Improve readability. - [x] Add unit tests for new `io.ts.` functions. - [x] Add this bug fix from this PR: https://github.com/langchain-ai/langgraph/pull/345 ### Next Steps 1. Update `pregel/index.ts` (`Pregel` and `Channel` classes). 2. Migrate `RunnableLambda` to `RunnableCallable`. 3. Update `pregel/validate.ts` (I think). --- <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#504