-
-
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 test for LazyOption init - move ZnTypes and DVCOptions to structs module
Showing
4 changed files
with
62 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import pytest | ||
|
||
from zntrack.utils.structs import LazyOption | ||
|
||
|
||
def test_noLazyOptionInit(): | ||
with pytest.raises(ValueError): | ||
LazyOption() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import enum | ||
|
||
|
||
class LazyOption: | ||
def __init__(self): | ||
raise ValueError( | ||
"Can not initialize LazyOption. If you expected something else open an " | ||
"issue at https://github.com/zincware/ZnTrack and describe how you got here." | ||
) | ||
|
||
|
||
class ZnTypes(enum.Enum): | ||
"""Collection of ZnTrack Types to identify descriptors beyond their dvc option | ||
Attributes | ||
---------- | ||
results: most zn.<options> like zn.outs() / zn.metrics() use this one | ||
""" | ||
|
||
DEPS = enum.auto() | ||
DVC = enum.auto() | ||
METADATA = enum.auto() | ||
# method = enum.auto() | ||
PARAMS = enum.auto() | ||
ITERABLE = enum.auto() | ||
RESULTS = enum.auto() | ||
|
||
|
||
FILE_DVC_TRACKED = [ZnTypes.DVC] | ||
# if the getattr(instance, self.name) is an affected file, | ||
# e.g. the dvc.<outs> is a file / list of files | ||
VALUE_DVC_TRACKED = [ZnTypes.RESULTS, ZnTypes.METADATA] | ||
|
||
|
||
# if the internal file, | ||
# e.g. in the case of zn.outs() like nodes/<node_name>/outs.json is an affected file | ||
|
||
|
||
class DVCOptions(enum.Enum): | ||
# Use enum over dataclass because it is iterable | ||
PARAMS = "params" | ||
DEPS = "deps" | ||
OUTS = "outs" | ||
CHECKPOINTS = "checkpoints" | ||
OUTS_NO_CACHE = "outs_no_cache" | ||
OUTS_PERSISTENT = "outs_persistent" | ||
METRICS = "metrics" | ||
METRICS_NO_CACHE = "metrics_no_cache" | ||
PLOTS = "plots" | ||
PLOTS_NO_CACHE = "plots_no_cache" |