Skip to content

Commit

Permalink
fix #523
Browse files Browse the repository at this point in the history
  • Loading branch information
PythonFZ committed Mar 17, 2023
1 parent 184334e commit a8c3e35
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
16 changes: 8 additions & 8 deletions tests/integration/test_file_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def run(self):
self.outs = "correct outs"


# def test_WriteToOutsOutsideRun(proj_path):
# node = WriteToOutsOutsideRun(outs="correct outs")
# node.run()
# node.save()
#
# assert WriteToOutsOutsideRun.from_rev().outs == "correct outs"
# # WriteToOutsOutsideRun(outs="incorrect outs").save()
# # assert WriteToOutsOutsideRun.from_rev().outs == "correct outs"
def test_WriteToOutsOutsideRun(proj_path):
node = WriteToOutsOutsideRun(outs="correct outs")
node.run()
node.save()

assert WriteToOutsOutsideRun.from_rev().outs == "correct outs"
WriteToOutsOutsideRun(outs="incorrect outs").save(results=False)
assert WriteToOutsOutsideRun.from_rev().outs == "correct outs"
4 changes: 3 additions & 1 deletion tests/integration/test_node_nwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class WriteToNWD(zntrack.Node):
def run(self):
self.nwd.mkdir(exist_ok=True, parents=True)
self.file[0].write_text(self.text)



class OutsAsNWD(zntrack.Node):
text = zntrack.zn.params()
outs: pathlib.Path = zntrack.dvc.outs(zntrack.nwd)
Expand All @@ -33,6 +34,7 @@ def test_WriteToNWD(proj_path, eager):
write_to_nwd.load()
assert write_to_nwd.__dict__["file"] == [pathlib.Path("$nwd$", "test.txt")]


@pytest.mark.parametrize("eager", [True, False])
def test_OutAsNWD(proj_path, eager):
with zntrack.Project() as project:
Expand Down
2 changes: 1 addition & 1 deletion zntrack/utils/node_wd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def default(self, value, **kwargs):
if isinstance(value, str):
if value == nwd:
# nwd is of type str but will be converted to pathlib.Path
return pathlib.Path(kwargs["nwd"])
return pathlib.Path(kwargs["nwd"])
return value.replace(nwd, pathlib.Path(kwargs["nwd"]).as_posix())
elif isinstance(value, pathlib.Path):
return pathlib.Path(
Expand Down

0 comments on commit a8c3e35

Please sign in to comment.