-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(langgraph-base): create async get_tuple method + tests #325
base: langgraph-base
Are you sure you want to change the base?
feat(langgraph-base): create async get_tuple method + tests #325
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems similar to the alist PR and doesn't contain get_tuple method.
Please reopen when there are changes. |
@averikitsch how can I open the PR? |
/gcbrun |
/gcbrun |
result = await conn.execute(text(query), args) | ||
result_map = result.mappings() | ||
results = result_map.fetchall() | ||
for value in results: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be truly async we need to fetch asynchronously not fetchall into memory.
result = await conn.execute(text(query), args) | |
result_map = result.mappings() | |
results = result_map.fetchall() | |
for value in results: | |
result_proxy = await conn.execute(text(query), args) | |
while True: | |
value = result_proxy.fetchone() |
) | ||
from langgraph.checkpoint.serde.base import SerializerProtocol | ||
from langgraph.checkpoint.serde.jsonplus import JsonPlusSerializer | ||
from langgraph.checkpoint.serde.types import TASKS | ||
from langgraph.checkpoint.serde.types import TASKS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove double import
CheckpointTuple, | ||
get_checkpoint_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove double import
AND cw.checkpoint_id = c.parent_checkpoint_id | ||
AND cw.channel = '{TASKS}' | ||
) AS pending_sends | ||
FROM "{self.schema_name}".'{CHECKPOINTS_TABLE}' c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use double quotes around all table name
metadata, | ||
( | ||
SELECT array_agg(array[cw.task_id::text::bytea, cw.channel::bytea, cw.type::bytea, cw.blob] order by cw.task_id, cw.idx) | ||
FROM "{self.schema_name}".'{CHECKPOINT_WRITES_TABLE}' cw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All table names should refer to the self.table_name and self.table_name_writes
}, | ||
checkpoint=self._load_checkpoint( | ||
value["checkpoint"], | ||
value["channel_values"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we calculating this?
async with self.pool.connect() as conn: | ||
result = await conn.execute(text(SELECT + where), args) | ||
result_map = result.mappings() | ||
results = result_map.fetchall() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use fetchone()
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you copy in the tests that use get_tuple from https://github.com/langchain-ai/langgraph/blob/909190cede6a80bb94a2d4cfe7dedc49ef0d4127/libs/langgraph/tests/test_prebuilt.py
At some point we will also want larger tests like https://github.com/langchain-ai/langgraph/blob/909190cede6a80bb94a2d4cfe7dedc49ef0d4127/libs/langgraph/tests/test_pregel.py
Change Log:
[ ] Create async get_tuple method
[ ] Create test for method