-
-
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 `prepare_dvc_script` for `nodify` and `Node` * add tests * fix test * add docstrings * all dotdict on all NodeConfig attributes * add NodeConfig dotdict test - test NodeConfig.convert_fields_to_dotdict()
- Loading branch information
Showing
7 changed files
with
335 additions
and
117 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,48 @@ | ||
import pathlib | ||
|
||
import pytest | ||
|
||
from zntrack.core.functions.decorator import NodeConfig | ||
|
||
|
||
def test_not_supported_outs(): | ||
with pytest.raises(ValueError): | ||
NodeConfig(outs=25) | ||
with pytest.raises(ValueError): | ||
NodeConfig(outs=[25]) | ||
with pytest.raises(ValueError): | ||
NodeConfig(outs={"path": 25}) | ||
|
||
assert NodeConfig(outs="path").outs == "path" | ||
|
||
|
||
def test_not_supported_params(): | ||
with pytest.raises(ValueError): | ||
NodeConfig(params=25) | ||
with pytest.raises(ValueError): | ||
NodeConfig(params=[25]) | ||
|
||
|
||
def test_supported_params(): | ||
assert NodeConfig(params={"name": "John"}).params["name"] == "John" | ||
|
||
|
||
def test_NodeConfig_convert_fields_to_dotdict(): | ||
cfg = NodeConfig(outs="file") | ||
assert cfg.outs == "file" | ||
|
||
cfg = NodeConfig(outs={"file": "file.txt"}) | ||
cfg.convert_fields_to_dotdict() | ||
assert cfg.outs.file == "file.txt" | ||
assert cfg.outs["file"] == "file.txt" | ||
|
||
cfg = NodeConfig(outs={"files": {"data": "datafile.txt"}}) | ||
cfg.convert_fields_to_dotdict() | ||
assert cfg.outs.files.data == "datafile.txt" | ||
|
||
cfg = NodeConfig( | ||
outs={"files": {"file": "datafile.txt", "path": pathlib.Path("data.txt")}} | ||
) | ||
cfg.convert_fields_to_dotdict() | ||
assert cfg.outs.files.file == "datafile.txt" | ||
assert cfg.outs.files.path == pathlib.Path("data.txt") |
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
Oops, something went wrong.