Skip to content

Commit

Permalink
fix save
Browse files Browse the repository at this point in the history
  • Loading branch information
PythonFZ committed Apr 10, 2023
1 parent 29848e8 commit 6a154e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/integration/test_dvc_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ class NodeWithPlotsZnGlobal(zntrack.Node):
title="title",
template="linear",
)
metrics = zntrack.zn.metrics()

def run(self) -> None:
self.data = pd.DataFrame({"x": [1, 2, 3], "y": [4, 5, 6], "z": [7, 8, 9]})
self.metrics = {"a": 1, "b": 2}

def get_data(self):
return self.data
Expand All @@ -71,10 +73,12 @@ class NodeWithPlotsDVCGlobal(zntrack.Node):
title="title",
template="linear",
)
metrics = zntrack.dvc.metrics(zntrack.nwd / "metrics.json")

def run(self) -> None:
df = pd.DataFrame({"x": [1, 2, 3], "y": [4, 5, 6], "z": [7, 8, 9]})
df.to_csv(self.data)
self.metrics.write_text("{'a': 1, 'b': 2}")

def get_data(self):
return pd.read_csv(self.data)
Expand Down Expand Up @@ -157,17 +161,22 @@ def test_multiple_plots_nodes(proj_path):
NodeWithPlotsZnGlobal()
NodeWithPlotsZnGlobal()
NodeWithPlotsDVCGlobal()
NodeWithPlotsDVCGlobal()
a = NodeWithPlotsDVCGlobal()
project.run()
run_dvc_cmd(["plots", "show"])

with project:
NodeWithPlotsZnGlobal()
NodeWithPlotsZnGlobal()
b = NodeWithPlotsZnGlobal()
NodeWithPlotsDVCGlobal()
NodeWithPlotsDVCGlobal()
project.run()
run_dvc_cmd(["plots", "show"])
# run_dvc_cmd(["repro", "-f"])

# check loading
NodeWithPlotsDVCGlobal.from_rev(name=a.name)
NodeWithPlotsZnGlobal.from_rev(name=b.name)


def test_NodeRemoteTemplate(proj_path):
Expand Down
2 changes: 2 additions & 0 deletions zntrack/fields/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ def save(self, instance: "Node"):
.as_posix()
)

with contextlib.suppress(NotImplementedError):
super().save(instance=instance)
if not self.use_global_plots:
return

Expand Down

0 comments on commit 6a154e6

Please sign in to comment.