Skip to content

Commit

Permalink
load from file
Browse files Browse the repository at this point in the history
  • Loading branch information
eagmon committed Feb 29, 2024
1 parent fa33cb9 commit 1303b50
Show file tree
Hide file tree
Showing 2 changed files with 263 additions and 26 deletions.
12 changes: 12 additions & 0 deletions builder/builder_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,16 @@ def __init__(
schema=None,
tree=None,
core=None,
file_path=None,
):
schema = schema or {}
tree = tree or {}

if file_path:
with open(file_path, 'r') as file:
graph_data = json.load(file)
tree = deep_merge(tree, graph_data)

self.core = core or ProcessTypes()
self.schema, self.tree = self.core.complete(schema, tree)
self.node = node_from_tree(self, self.schema, self.tree)
Expand Down Expand Up @@ -393,6 +399,12 @@ def test_builder():
# save document
builder.write(filename='builder_test_doc')

# load builder from document
builder2 = Builder(core=core, file_path='out/builder_test_doc.json')
builder.visualize(filename='builder_test4',
show_values=True,
show_types=True)


if __name__ == '__main__':
test_builder()
Loading

0 comments on commit 1303b50

Please sign in to comment.