Undo addition of Send.id

This commit is contained in:
Nuno Campos
2024-08-27 13:34:50 -07:00
parent a8758661bc
commit 499fe10ef2
5 changed files with 8 additions and 13 deletions
@@ -109,7 +109,7 @@ class JsonPlusSerializer(SerializerProtocol):
return self._encode_constructor_args(obj.__class__, args=[obj.value])
elif isinstance(obj, SendProtocol):
return self._encode_constructor_args(
obj.__class__, kwargs={"node": obj.node, "arg": obj.arg, "id": obj.id}
obj.__class__, kwargs={"node": obj.node, "arg": obj.arg}
)
elif isinstance(obj, (bytes, bytearray)):
return self._encode_constructor_args(
@@ -50,7 +50,6 @@ class SendProtocol(Protocol):
# Mirrors langgraph.constants.Send
node: str
arg: Any
id: str
def __hash__(self) -> int: ...
+4 -7
View File
@@ -1,6 +1,5 @@
from dataclasses import dataclass
from typing import Any, Literal, Optional
from uuid import uuid4
from typing import Any, Literal
INPUT = "__input__"
CONFIG_KEY_SEND = "__pregel_send"
@@ -79,9 +78,8 @@ class Send:
node: str
arg: Any
id: Optional[str]
def __init__(self, /, node: str, arg: Any, id: Optional[str] = None) -> None:
def __init__(self, /, node: str, arg: Any) -> None:
"""
Initialize a new instance of the Send class.
@@ -92,13 +90,12 @@ class Send:
"""
self.node = node
self.arg = arg
self.id = id or str(uuid4())
def __hash__(self) -> int:
return hash((self.node, self.arg, self.id))
return hash((self.node, self.arg))
def __repr__(self) -> str:
return f"Send(node={self.node!r}, arg={self.arg!r}, id={self.id!r})"
return f"Send(node={self.node!r}, arg={self.arg!r})"
def __eq__(self, value: object) -> bool:
return (
+3 -3
View File
@@ -291,9 +291,9 @@ def prepare_next_tasks(
"langgraph_task_idx": len(tasks),
}
checkpoint_ns = (
f"{parent_ns}{CHECKPOINT_NAMESPACE_SEPARATOR}{packet.node}:{packet.id}"
f"{parent_ns}{CHECKPOINT_NAMESPACE_SEPARATOR}{packet.node}"
if parent_ns
else f"{packet.node}:{packet.id}"
else packet.node
)
task_id = str(
uuid5(UUID(checkpoint["id"]), json.dumps((checkpoint_ns, metadata)))
@@ -344,7 +344,7 @@ def prepare_next_tasks(
CONFIG_KEY_CHECKPOINTER: checkpointer,
CONFIG_KEY_RESUMING: is_resuming,
"checkpoint_id": checkpoint["id"],
"checkpoint_ns": checkpoint_ns,
"checkpoint_ns": f"{checkpoint_ns}:{task_id}",
},
),
triggers,
-1
View File
@@ -118,7 +118,6 @@ class PregelLoop:
checkpoint_config: RunnableConfig
checkpoint_metadata: CheckpointMetadata
checkpoint_pending_writes: List[PendingWrite]
# (thread_id, checkpoint_ns -> channel_versions)
checkpoint_previous_versions: dict[str, Union[str, float, int]]
step: int