-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
zntrack.config
to update default values (#870)
* add `zntrack.config` to update default values * update version * update tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add metrics * fix test * update tests, use `zntrack.config` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3cd1929
commit 44e484c
Showing
10 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
stages: | ||
MyNode: | ||
cmd: zntrack run test_user_config.MyNode --name MyNode | ||
metrics: | ||
- nodes/MyNode/metric.json | ||
- nodes/MyNode/node-meta.json: | ||
cache: true | ||
- nodes/MyNode/results.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"""Test params such as always_changed, ...""" | ||
|
||
import json | ||
import pathlib | ||
|
||
import yaml | ||
|
||
import zntrack | ||
|
||
CWD = pathlib.Path(__file__).parent.resolve() | ||
|
||
|
||
def test_node(proj_path): | ||
assert zntrack.config.ALWAYS_CACHE is False | ||
zntrack.config.ALWAYS_CACHE = True | ||
assert zntrack.config.ALWAYS_CACHE is True | ||
|
||
# We define the node here, because the config has to be set | ||
# bevore calling zntrack.metrics() | ||
class MyNode(zntrack.Node): | ||
"""Some Node.""" | ||
|
||
metric: dict = zntrack.metrics() | ||
metrics_path: pathlib.Path = zntrack.metrics_path(zntrack.nwd / "results.json") | ||
|
||
def run(self) -> None: | ||
self.metric = {"a": 1, "b": 2} | ||
|
||
with zntrack.Project() as proj: | ||
node = MyNode() | ||
|
||
proj.build() | ||
|
||
zntrack.config.ALWAYS_CACHE = False # reset to default value | ||
assert zntrack.config.ALWAYS_CACHE is False | ||
|
||
assert json.loads( | ||
(CWD / "zntrack_config" / "user_config.json").read_text() | ||
) == json.loads((proj_path / "zntrack.json").read_text()) | ||
assert yaml.safe_load( | ||
(CWD / "dvc_config" / "user_config.yaml").read_text() | ||
) == yaml.safe_load((proj_path / "dvc.yaml").read_text()) | ||
assert (CWD / "params_config" / "user_config.yaml").read_text() == ( | ||
proj_path / "params.yaml" | ||
).read_text() | ||
|
||
|
||
if __name__ == "__main__": | ||
test_node("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"MyNode": { | ||
"nwd": { | ||
"_type": "pathlib.Path", | ||
"value": "nodes/MyNode" | ||
}, | ||
"metrics_path": { | ||
"_type": "pathlib.Path", | ||
"value": "$nwd$/results.json" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters