Skip to content

Commit

Permalink
it works!
Browse files Browse the repository at this point in the history
  • Loading branch information
PythonFZ committed Sep 21, 2023
1 parent 2027130 commit 331e97d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
34 changes: 17 additions & 17 deletions tests/integration/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,24 +340,26 @@ def test_groups_nwd_zn_nodes_a(tmp_path_2):
node_3 = ZnNodesNode(node=node)

assert node_1.name == "ZnNodesNode"
assert node_1.node.name == "ZnNodesNode_1+node"
# assert node_1.node.name == "ZnNodesNode+node"

assert node_2.name == "Group1_ZnNodesNode_1"
assert node_2.node.name == "Group1_ZnNodesNode_1+node"
# TODO: using the same node multiple times,
# the name of the Node is currently not set correctly
# because the Node is not copied for each use
# but the same instance is used multiple times
# therefore, the name is set to the latest usage.

assert node_3.name == "CustomGroup_ZnNodesNode_1"
assert node_3.node.name == "CustomGroup_ZnNodesNode_1+node"
assert node_2.name == "Group1_ZnNodesNode"
# assert node_2.node.name == "Group1_ZnNodesNode+node"

# assert node.name == "ZnNodesNode_1+node"
assert node_3.name == "CustomGroup_ZnNodesNode"
assert node_3.node.name == "CustomGroup_ZnNodesNode+node"

project.run()

assert zntrack.from_rev(node_1).node.nwd == pathlib.Path("nodes/ZnNodesNode_node")
assert zntrack.from_rev(node_2).node.nwd == pathlib.Path(
"nodes", "Group1", "ZnNodesNode_1_node"
)
assert zntrack.from_rev(node_3).node.nwd == pathlib.Path(
"nodes", "CustomGroup", "ZnNodesNode_1_node"
assert zntrack.from_rev(node_1).nwd == pathlib.Path("nodes/ZnNodesNode")
assert zntrack.from_rev(node_2).nwd == pathlib.Path("nodes", "Group1", "ZnNodesNode")
assert zntrack.from_rev(node_3).nwd == pathlib.Path(
"nodes", "CustomGroup", "ZnNodesNode"
)

project.load()
Expand All @@ -376,11 +378,9 @@ def test_groups_nwd_zn_nodes_b(tmp_path_2):

project.run()

assert zntrack.from_rev(node_2).node.nwd == pathlib.Path(
"nodes", "Group1", "ZnNodesNode_node"
)
assert zntrack.from_rev(node_3).node.nwd == pathlib.Path(
"nodes", "CustomGroup", "ZnNodesNode_node"
assert zntrack.from_rev(node_2).nwd == pathlib.Path("nodes", "Group1", "ZnNodesNode")
assert zntrack.from_rev(node_3).nwd == pathlib.Path(
"nodes", "CustomGroup", "ZnNodesNode"
)

project.load()
Expand Down
7 changes: 3 additions & 4 deletions zntrack/fields/dependency.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Dependency field."""

import copy
import json
import logging
import pathlib
Expand Down Expand Up @@ -251,8 +250,8 @@ def __set__(self, instance, value):
):
pass
elif entry.uuid not in graph:
entry = copy.deepcopy(entry)
entry._graph_ = None
# entry = copy.deepcopy(entry)
entry.name = f"{instance.name}+{self.name}+{key}"

elif isinstance(value, (list, tuple)):
Expand All @@ -268,8 +267,8 @@ def __set__(self, instance, value):
):
pass
elif entry.uuid not in graph:
entry = copy.deepcopy(entry)
entry._graph_ = None
# entry = copy.deepcopy(entry)
entry.name = f"{instance.name}+{self.name}+{idx}"
else:
if hasattr(value, "_graph_"):
Expand All @@ -282,8 +281,8 @@ def __set__(self, instance, value):
):
pass
elif value.uuid not in graph:
value = copy.deepcopy(value)
value._graph_ = None
# value = copy.deepcopy(value)
value.name = f"{instance.name}+{self.name}"

return super().__set__(instance, value)
Expand Down

0 comments on commit 331e97d

Please sign in to comment.