From 414ac6aa2ee491e1b1a64add9dca3686e32d40f4 Mon Sep 17 00:00:00 2001 From: PythonFZ Date: Thu, 21 Sep 2023 18:25:48 +0200 Subject: [PATCH 1/4] deprecated zntrack.zn and zntrack.dvc --- poetry.lock | 2 +- pyproject.toml | 1 + zntrack/fields/dvc/__init__.py | 10 ++++++++++ zntrack/fields/zn/__init__.py | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index f1791a5e..3a5d6e1e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -5534,4 +5534,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.8,<4.0.0" -content-hash = "7d787bc3f767e051b188aa81732499fce9e294aa0b899e2369cb69dc51c72a0c" +content-hash = "094010c5f8f6ae2f7fa142031fa5e11f4527d7cb6062a397fb2057bf488a9608" diff --git a/pyproject.toml b/pyproject.toml index 1d7e30c8..3b0362ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ dot4dict = "^0.1.1" zninit = "^0.1.11" znjson = "^0.2.2" znflow = "^0.1.14" +typing-extensions = "^4.8.0" [tool.poetry.urls] diff --git a/zntrack/fields/dvc/__init__.py b/zntrack/fields/dvc/__init__.py index 20ee07f3..1ebb5726 100644 --- a/zntrack/fields/dvc/__init__.py +++ b/zntrack/fields/dvc/__init__.py @@ -3,6 +3,7 @@ import pathlib import typing +import typing_extensions as tyex import znjson from zntrack.fields.field import Field, FieldGroup, PlotsMixin @@ -140,46 +141,55 @@ class PlotsOption(PlotsMixin, DVCOption): """Field with DVC plots kwargs.""" +@tyex.deprecated("Use 'zntrack.outs_path' instead.") def outs(*args, **kwargs) -> DVCOption: """Create a outs field.""" return DVCOption(*args, dvc_option="outs", **kwargs) +@tyex.deprecated("Use 'zntrack.params_path' instead.") def params(*args, **kwargs) -> DVCOption: """Create a params field.""" return DVCOption(*args, dvc_option="params", **kwargs) +@tyex.deprecated("Use 'zntrack.deps_path' instead.") def deps(*args, **kwargs) -> DVCOption: """Create a deps field.""" return DVCOption(*args, dvc_option="deps", **kwargs) +@tyex.deprecated("Use 'zntrack.outs_path' instead.") def outs_no_cache(*args, **kwargs) -> DVCOption: """Create a outs_no_cache field.""" return DVCOption(*args, dvc_option="outs-no-cache", **kwargs) +@tyex.deprecated("Use 'zntrack.outs_path' instead.") def outs_persistent(*args, **kwargs) -> DVCOption: """Create a outs_persistent field.""" return DVCOption(*args, dvc_option="outs-persistent", **kwargs) +@tyex.deprecated("Use 'zntrack.metrics_path' instead.") def metrics(*args, **kwargs) -> DVCOption: """Create a metrics field.""" return DVCOption(*args, dvc_option="metrics", **kwargs) +@tyex.deprecated("Use 'zntrack.metrics_path' instead.") def metrics_no_cache(*args, **kwargs) -> DVCOption: """Create a metrics_no_cache field.""" return DVCOption(*args, dvc_option="metrics-no-cache", **kwargs) +@tyex.deprecated("Use 'zntrack.plots_path' instead.") def plots(*args, **kwargs) -> DVCOption: """Create a plots field.""" return PlotsOption(*args, dvc_option="plots", **kwargs) +@tyex.deprecated("Use 'zntrack.plots_path' instead.") def plots_no_cache(*args, **kwargs) -> DVCOption: """Create a plots_no_cache field.""" return PlotsOption(*args, dvc_option="plots-no-cache", **kwargs) diff --git a/zntrack/fields/zn/__init__.py b/zntrack/fields/zn/__init__.py index 691f284f..f1a3dae2 100644 --- a/zntrack/fields/zn/__init__.py +++ b/zntrack/fields/zn/__init__.py @@ -6,6 +6,7 @@ import typing import pandas as pd +import typing_extensions as tyex import yaml import znflow import znflow.utils @@ -566,31 +567,37 @@ def get_files(self, instance: "Node") -> list: ] +@tyex.deprecated("Use 'zntrack.params' instead.") def params(*args, **kwargs) -> Params: """Create a params field.""" return Params(*args, **kwargs) +@tyex.deprecated("Use 'zntrack.deps' instead.") def deps(*args, **kwargs) -> Dependency: """Create a dependency field.""" return Dependency(*args, **kwargs) +@tyex.deprecated("Use 'zntrack.outs' instead.") def outs() -> Output: """Create an output field.""" return Output(dvc_option="outs", use_repr=False) +@tyex.deprecated("Use 'zntrack.metrics' instead.") def metrics() -> Output: """Create a metrics output field.""" return Output(dvc_option="metrics-no-cache") +@tyex.deprecated("Use 'zntrack.plots' instead.") def plots(*args, **kwargs) -> Plots: """Create a metrics output field.""" return Plots(*args, **kwargs) +@tyex.deprecated("Use 'zntrack.deps' instead.") def nodes(*args, **kwargs) -> NodeField: """Create a node field.""" return NodeField(*args, **kwargs) From b8ed2ff24a8803349fa83f95d81ec8f1b120c8dd Mon Sep 17 00:00:00 2001 From: PythonFZ Date: Thu, 21 Sep 2023 18:50:31 +0200 Subject: [PATCH 2/4] deprecate 'zntrack.zn' and 'zntrack.dvc' modules --- zntrack/core/node.py | 5 +- zntrack/fields/dependency.py | 4 +- zntrack/fields/dvc/__init__.py | 165 +-------- zntrack/fields/dvc/options.py | 141 ++++++++ zntrack/fields/fields.py | 65 ++-- zntrack/fields/zn/__init__.py | 593 +-------------------------------- zntrack/fields/zn/options.py | 567 +++++++++++++++++++++++++++++++ 7 files changed, 788 insertions(+), 752 deletions(-) create mode 100644 zntrack/fields/dvc/options.py create mode 100644 zntrack/fields/zn/options.py diff --git a/zntrack/core/node.py b/zntrack/core/node.py index 40119b39..09c0308a 100644 --- a/zntrack/core/node.py +++ b/zntrack/core/node.py @@ -175,10 +175,11 @@ def convert_notebook(cls, nb_name: str = None): def _init_descriptors_(self): from zntrack import fields from zntrack.fields.dependency import Dependency + from zntrack.fields.zn import options as zn_options return [ - fields.zn.Params, - fields.zn.Dependency, + zn_options.Params, + zn_options.Dependency, Dependency, fields.meta.Text, fields.meta.Environment, diff --git a/zntrack/fields/dependency.py b/zntrack/fields/dependency.py index f5183363..fde87ec8 100644 --- a/zntrack/fields/dependency.py +++ b/zntrack/fields/dependency.py @@ -11,7 +11,7 @@ from znflow import handler from zntrack.fields.field import DataIsLazyError, Field, FieldGroup, LazyField -from zntrack.fields.zn import ( +from zntrack.fields.zn.options import ( CombinedConnectionsConverter, ConnectionConverter, _default, @@ -458,7 +458,7 @@ def get_stage_add_argument(self, instance) -> t.List[tuple]: # TODO this is only for parameters via `zn.params` # we need to also handle parameters via `dvc.params` - from zntrack.fields.zn import Params + from zntrack.fields.zn.options import Params # NO: we have to do this for each value and for instance diff --git a/zntrack/fields/dvc/__init__.py b/zntrack/fields/dvc/__init__.py index 1ebb5726..ff9724be 100644 --- a/zntrack/fields/dvc/__init__.py +++ b/zntrack/fields/dvc/__init__.py @@ -1,195 +1,64 @@ -"""DVC fields without serialization of data / for file paths.""" -import json -import pathlib -import typing +"""Deprecated module for 'zntrack.dvc.