Skip to content

Commit

Permalink
Merge pull request #2087 from langchain-ai/nc/11oct/o-flag
Browse files Browse the repository at this point in the history
fix: Work w python's O flag
  • Loading branch information
nfcampos authored Oct 11, 2024
2 parents 66741ba + fc20de5 commit c9adf99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions libs/langgraph/langgraph/pregel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,10 @@ def update_state(
if saved:
checkpointer.put_writes(checkpoint_config, task.writes, task_id)
# apply to checkpoint and save
assert not apply_writes(
mv_writes = apply_writes(
checkpoint, channels, [task], checkpointer.get_next_version
), "Can't write to SharedValues from update_state"
)
assert not mv_writes, "Can't write to SharedValues from update_state"
checkpoint = create_checkpoint(checkpoint, channels, step + 1)
next_config = checkpointer.put(
checkpoint_config,
Expand Down Expand Up @@ -1011,9 +1012,10 @@ async def aupdate_state(
if saved:
await checkpointer.aput_writes(checkpoint_config, writes, task_id)
# apply to checkpoint and save
assert not apply_writes(
mv_writes = apply_writes(
checkpoint, channels, [task], checkpointer.get_next_version
), "Can't write to SharedValues from update_state"
)
assert not mv_writes, "Can't write to SharedValues from update_state"
checkpoint = create_checkpoint(checkpoint, channels, step + 1)
next_config = await checkpointer.aput(
checkpoint_config,
Expand Down
5 changes: 3 additions & 2 deletions libs/langgraph/langgraph/pregel/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,13 @@ def _first(self, *, input_keys: Union[str, Sequence[str]]) -> None:
manager=None,
)
# apply input writes
assert not apply_writes(
mv_writes = apply_writes(
self.checkpoint,
self.channels,
[*discard_tasks.values(), PregelTaskWrites(INPUT, input_writes, [])],
self.checkpointer_get_next_version,
), "Can't write to SharedValues in graph input"
)
assert not mv_writes, "Can't write to SharedValues in graph input"
# save input checkpoint
self._put_checkpoint({"source": "input", "writes": dict(input_writes)})
elif CONFIG_KEY_RESUMING not in configurable:
Expand Down

0 comments on commit c9adf99

Please sign in to comment.