Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 1, 2025
1 parent 361f52c commit b82781d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 4 additions & 5 deletions tests/files/test_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ def test_names(proj_path):
zntrack.examples.ParamsToMetrics(params={"loss": 0.09}, name="Lorine")
# # zntrack.examples.ParamsToMetrics(params={"loss": 0.09}, name="Lorine") # ValueError


project.build()

assert json.loads(
(CWD / "zntrack_config" / "names.json").read_text()
) == json.loads((proj_path / "zntrack.json").read_text())
assert json.loads((CWD / "zntrack_config" / "names.json").read_text()) == json.loads(
(proj_path / "zntrack.json").read_text()
)
assert yaml.safe_load(
(CWD / "dvc_config" / "names.yaml").read_text()
) == yaml.safe_load((proj_path / "dvc.yaml").read_text())
assert (CWD / "params_config" / "names.yaml").read_text() == (
proj_path / "params.yaml"
).read_text()
).read_text()
5 changes: 3 additions & 2 deletions tests/unit_tests/test_node_name.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

import zntrack


Expand Down Expand Up @@ -40,7 +41,7 @@ def test_duplicate_named_node_error(proj_path):
"""Test that an explicitly named node cannot be duplicated"""
with zntrack.Project() as project:
MyNode(name="A")

with pytest.raises(ValueError, match="A node with the name 'A' already exists."):
with project:
MyNode(name="A")
Expand Down Expand Up @@ -108,7 +109,7 @@ def test_nested_grouped_custom_node_names(proj_path):

assert n1.name == "A_B_Alpha"
assert n2.name == "A_B_Beta"

project.build()

assert n1.name == "A_B_Alpha"
Expand Down
3 changes: 2 additions & 1 deletion zntrack/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

log = logging.getLogger(__name__)


class _FinalNodeNameString(str):
"""A string that represents the final name of a node.
Used to differentiate between a custom name and a computed name.
"""

Expand Down

0 comments on commit b82781d

Please sign in to comment.