Repository navigation
feat(dynaflow): code ⇄ visual round-trip (import/export graph as code) (#292) - #356
Merged
Kaap10 merged 2 commits intoNov 23, 2026
Conversation
7 of 8 tasks
Kaap10
requested changes
Nov 21, 2026
Kaap10
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for working on this! The bidirectional code ⇄ visual round-trip is well-structured, and using Python's ast module for safe parsing without eval/exec is great for security.
Before we can merge, please address the following issues:
- Global Registry Overwrite Side-Effect: In
import_graph_from_code, when encountering@custom_node, it registers a dummy function returning{}withregister=Trueinto the globalnode_registry. If that node type was already registered in the application, this overwrites the real function with a dummy stub. - Variable References in AST Parsing:
import_graph_from_codeonly supports inline dictionary/call literals forconfig,mapping, andretry_policy. If a user writescfg = {"temp": 0.5}; LLMNode(..., config=cfg)or definespolicy = RetryPolicy(...)as a variable, parsing fails with aValueErroror drops the policy. - Private Attribute Assignment:
export_graph_to_codeoutputsgraph._execution_order = [...]. Generated code should avoid directly mutating private attributes. Callinggraph.add_node(...)in order already sets this naturally. - Exporting Custom Nodes: Exporting a graph with custom nodes emits
node_registry.get("type")(...). The generated code is not runnable on its own unless the custom node is pre-registered. Please document this requirement or add a comment in the generated code. - PR Description Formatting: The PR description has escaped backslashes (e.g.
\export_graph_to_code...\,\eval()\/ \exec()\) and an unprintable control character (\^Gst.parse\). Please format it according to.github/pull_request_template.md.
See the inline comments below for specific line references and suggested fixes.
…and registry safety (codeforstartups#292)
Collaborator
Author
|
Thanks @Kaap10 for the detailed review! All comments have been resolved:
|
Kaap10
approved these changes
Nov 23, 2026
Kaap10
left a comment
Collaborator
There was a problem hiding this comment.
LGTM! Thanks for addressing the feedback on AST variable resolution, registry safety, and encapsulation. Approved and ready to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduces bidirectional code ⇄ visual round-trip capabilities in dynaflow, allowing SimpleGraph instances to be exported to runnable Python SDK code and imported safely back via static AST parsing without arbitrary code execution (no eval/exec), addressing issue #292.
Related issue
Fixes #292
Changes
export_graph_to_codeinsrc/dynavec/nodes/codegen.py:import_graph_from_codewith safe static AST analysis:SimpleGraph.to_code()andSimpleGraph.from_code(code_str).tests/test_nodes_roundtrip.pyvalidating lossless round-trips, multi-node pipelines, re-execution of reconstructed graphs, variable resolution, registry preservation, and AST safety.Testing
pytest tests/test_nodes_roundtrip.py tests/test_nodes.py-> 48 passed)ruff check src/dynavec/nodes/codegen.py tests/test_nodes_roundtrip.py-> All checks passed)mypy src/dynavec/nodes/codegen.py-> Success: no issues found)Checklist