Skip to content
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

Serialization Error #3289

Open
4 tasks done
BharahthyKannan opened this issue Feb 3, 2025 · 3 comments
Open
4 tasks done

Serialization Error #3289

BharahthyKannan opened this issue Feb 3, 2025 · 3 comments

Comments

@BharahthyKannan
Copy link

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

builder = StateGraph(State)
builder.add_node(call_llm)
builder.add_node(run_tool)
builder.add_node(human_review_node)
builder.add_edge(START, "call_llm")
builder.add_conditional_edges("call_llm", route_after_llm)
builder.add_edge("run_tool", "call_llm")
This is the simple Graph

Error Message and Stack Trace (if applicable)

Description

I am trying to serialize compiledstategraph object to use across API calls. I tried to pickle, getting this below error
b'"Can't pickle local object 'CompgiledStateGraph.attach_node.._get_updates'"''

How to serialize the compilestategraph

System Info

Python

@hinthornw
Copy link
Contributor

Out of curiosity, why do you need to pickle the compiled graph?

State is managed via checkpointing. persistence across api calls, servers, etc. should all be covered by this. The graph object itself isn't usually pickled

@BharahthyKannan
Copy link
Author

@hinthornw I have build a fast api wrapper on top of Human in loop. I have two endpoint one for create call and another endpoint for resume.
In create call I create graph/workflow object. Once the interrupt issued I want to hit resume endpoint and need to use same object which is already created. I can get the state details via get_state.. still the graph object itself missing since it is function scoped.. If I can serialize then I can avoid creating graph everytime ..

@vbarda
Copy link
Collaborator

vbarda commented Feb 4, 2025

@BharahthyKannan there is no cost associated with creating state graph, so you can safely re-create it every time. did you have any other concerns besides that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants