Serializing / deserializing a workflow to write to DB #71
Closed
vaibhav-46
started this conversation in
General
Replies: 1 comment
-
@vaibhav-46 Thanks for the great question. from dynamiq.serializers.loaders.yaml import WorkflowYAMLLoader
WF_YAML_FILE_PATH = "wf.yaml"
# Create workflow
workflow = Workflow()
workflow.add_nodes([...])
# Save the workflow to a YAML file.
workflow.to_yaml_file(file_path=WF_YAML_FILE_PATH)
# Later, load the YAML back and re-create the workflow.
wf_data = WorkflowYAMLLoader.load(file_path=WF_YAML_FILE_PATH, init_components=True)
workflow_from_yaml = Workflow.from_yaml_file_data(file_data=wf_data) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been using Dynamiq for a while and it's been pretty useful to build micro-agents. One thing that I tried to implement but failed, is a way to create a workflow, serialize it to store it in the DB and then be able to deserialize it to get back the same state.
A very simple example :
This keeps failing because the NodeType is not retained when it's being re-created from the workflow_dict. Is there a way that I might not have found to get this to work? I do see the to_dict function, but I am not sure if there is a way to restore the workflow from the output of the to_dict function.
Beta Was this translation helpful? Give feedback.
All reactions