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

Load nodes after project.run #781

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/integration/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,16 @@ def test_magic_names(proj_path):
zntrack.from_rev(node02.name).outs == "Dolor Sit"
zntrack.from_rev(node03.name).outs == "Test01"
zntrack.from_rev(grp_node03.name).outs == "Test02"


def test_project_run_load(proj_path):
"""Ensure Nodes are loaded after project is run from the same script."""

project = zntrack.Project()

with project:
node = zntrack.examples.ParamsToOuts(params="Lorem Ipsum")

project.run()

assert node.outs == "Lorem Ipsum"
7 changes: 6 additions & 1 deletion zntrack/project/zntrack_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ def run(
node.save(results=False)
if not eager and repro:
self.repro()
# TODO should we load the nodes here? Maybe, if lazy loading is implemented.
# load the nodes
for node_uuid in self.graph.get_sorted_nodes():
node = self.graph.nodes[node_uuid]["value"]
if node_names is not None and node.name not in node_names:
continue
node.load()

if auto_remove:
self.auto_remove()
Expand Down
Loading