diff --git a/tests/unit_tests/utlis/test_structs.py b/tests/unit_tests/utlis/test_structs.py new file mode 100644 index 00000000..3bda571e --- /dev/null +++ b/tests/unit_tests/utlis/test_structs.py @@ -0,0 +1,8 @@ +import pytest + +from zntrack.utils.structs import LazyOption + + +def test_noLazyOptionInit(): + with pytest.raises(ValueError): + LazyOption() diff --git a/zntrack/utils/__init__.py b/zntrack/utils/__init__.py index b77b9f1b..28b5e524 100644 --- a/zntrack/utils/__init__.py +++ b/zntrack/utils/__init__.py @@ -10,13 +10,13 @@ """ from zntrack.utils import exceptions, file_io -from zntrack.utils.config import ( +from zntrack.utils.config import Files, config +from zntrack.utils.structs import ( FILE_DVC_TRACKED, VALUE_DVC_TRACKED, DVCOptions, - Files, + LazyOption, ZnTypes, - config, ) from zntrack.utils.utils import ( check_type, @@ -52,12 +52,5 @@ "FILE_DVC_TRACKED", "VALUE_DVC_TRACKED", "DVCOptions", + "LazyOption", ] - - -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." - ) diff --git a/zntrack/utils/config.py b/zntrack/utils/config.py index a92835a8..30da511f 100644 --- a/zntrack/utils/config.py +++ b/zntrack/utils/config.py @@ -9,7 +9,6 @@ Description: Configuration File for ZnTrack """ import dataclasses -import enum import logging from pathlib import Path @@ -70,45 +69,4 @@ class Files: params: Path = Path("params.yaml") -class ZnTypes(enum.Enum): - """Collection of ZnTrack Types to identify descriptors beyond their dvc option - - Attributes - ---------- - results: most zn. 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. 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//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" - - config = Config() diff --git a/zntrack/utils/structs.py b/zntrack/utils/structs.py new file mode 100644 index 00000000..f57cfbd3 --- /dev/null +++ b/zntrack/utils/structs.py @@ -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. 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. 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//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"