From 4b036d7c65a456c8b83b234174a30bf4340c3189 Mon Sep 17 00:00:00 2001 From: mg515 Date: Thu, 4 Apr 2024 12:19:13 +0200 Subject: [PATCH] rename plugin from flytekit-hydra into flytekit-omegaconf --- .../flytekit-hydra/flytekitplugins/hydra/__init__.py | 3 --- .../{flytekit-hydra => flytekit-omegaconf}/README.md | 12 +++++------- .../flytekitplugins/omegaconf/__init__.py | 3 +++ .../flytekitplugins/omegaconf}/config.py | 0 .../omegaconf}/dictconfig_transformer.py | 6 +++--- .../omegaconf}/extended_enum_transformer.py | 0 .../flytekitplugins/omegaconf}/flytekit_patch.py | 0 .../omegaconf}/listconfig_transformer.py | 6 +++--- .../flytekitplugins/omegaconf}/type_information.py | 2 +- .../{flytekit-hydra => flytekit-omegaconf}/setup.py | 8 ++++---- .../tests/__init__.py | 0 .../tests/conftest.py | 0 .../tests/test_extract_node_type.py | 2 +- .../tests/test_objects.py | 0 .../tests/test_plugin.py | 12 ++++++------ 15 files changed, 26 insertions(+), 28 deletions(-) delete mode 100644 plugins/flytekit-hydra/flytekitplugins/hydra/__init__.py rename plugins/{flytekit-hydra => flytekit-omegaconf}/README.md (90%) create mode 100644 plugins/flytekit-omegaconf/flytekitplugins/omegaconf/__init__.py rename plugins/{flytekit-hydra/flytekitplugins/hydra => flytekit-omegaconf/flytekitplugins/omegaconf}/config.py (100%) rename plugins/{flytekit-hydra/flytekitplugins/hydra => flytekit-omegaconf/flytekitplugins/omegaconf}/dictconfig_transformer.py (97%) rename plugins/{flytekit-hydra/flytekitplugins/hydra => flytekit-omegaconf/flytekitplugins/omegaconf}/extended_enum_transformer.py (100%) rename plugins/{flytekit-hydra/flytekitplugins/hydra => flytekit-omegaconf/flytekitplugins/omegaconf}/flytekit_patch.py (100%) rename plugins/{flytekit-hydra/flytekitplugins/hydra => flytekit-omegaconf/flytekitplugins/omegaconf}/listconfig_transformer.py (96%) rename plugins/{flytekit-hydra/flytekitplugins/hydra => flytekit-omegaconf/flytekitplugins/omegaconf}/type_information.py (97%) rename plugins/{flytekit-hydra => flytekit-omegaconf}/setup.py (87%) rename plugins/{flytekit-hydra => flytekit-omegaconf}/tests/__init__.py (100%) rename plugins/{flytekit-hydra => flytekit-omegaconf}/tests/conftest.py (100%) rename plugins/{flytekit-hydra => flytekit-omegaconf}/tests/test_extract_node_type.py (97%) rename plugins/{flytekit-hydra => flytekit-omegaconf}/tests/test_objects.py (100%) rename plugins/{flytekit-hydra => flytekit-omegaconf}/tests/test_plugin.py (94%) diff --git a/plugins/flytekit-hydra/flytekitplugins/hydra/__init__.py b/plugins/flytekit-hydra/flytekitplugins/hydra/__init__.py deleted file mode 100644 index 02b4a40bc3..0000000000 --- a/plugins/flytekit-hydra/flytekitplugins/hydra/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from flytekitplugins.hydra.dictconfig_transformer import DictConfigTransformer # noqa: F401 -from flytekitplugins.hydra.extended_enum_transformer import GenericEnumTransformer # noqa: F401 -from flytekitplugins.hydra.listconfig_transformer import ListConfigTransformer # noqa: F401 diff --git a/plugins/flytekit-hydra/README.md b/plugins/flytekit-omegaconf/README.md similarity index 90% rename from plugins/flytekit-hydra/README.md rename to plugins/flytekit-omegaconf/README.md index 9f11f4ad6d..8278ccc7c4 100644 --- a/plugins/flytekit-hydra/README.md +++ b/plugins/flytekit-omegaconf/README.md @@ -1,16 +1,14 @@ -# Flytekit Hydra Plugin +# Flytekit OmegaConf Plugin Flytekit python natively supports serialization of many data types for exchanging information between tasks. -The Flytekit Hydra Plugin extends these by the `DictConfig` type from the +The Flytekit OmegaConf Plugin extends these by the `DictConfig` type from the [OmegaConf package](https://omegaconf.readthedocs.io/) as well as related types that are being used by the [hydra package](https://hydra.cc/) for configuration management. - - ## Task example ``` from dataclasses import dataclass -import flytekitplugins.hydra # noqa F401 +import flytekitplugins.omegaconf # noqa F401 from flytekit import task, workflow from omegaconf import DictConfig @@ -55,8 +53,8 @@ dataclass definition is not available. This is the default mode. To set the mode either initialise the transformer with the `mode` argument or set the mode of the config directly: ```python -from flytekitplugins.hydra.config import SharedConfig, OmegaConfTransformerMode -from flytekitplugins.hydra import DictConfigTransformer +from flytekitplugins.omegaconf.config import SharedConfig, OmegaConfTransformerMode +from flytekitplugins.omegaconf import DictConfigTransformer # Set the mode directly on the transformer transformer_slim = DictConfigTransformer(mode=OmegaConfTransformerMode.DictConfig) diff --git a/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/__init__.py b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/__init__.py new file mode 100644 index 0000000000..68ddf5cf79 --- /dev/null +++ b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/__init__.py @@ -0,0 +1,3 @@ +from flytekitplugins.omegaconf.dictconfig_transformer import DictConfigTransformer # noqa: F401 +from flytekitplugins.omegaconf.extended_enum_transformer import GenericEnumTransformer # noqa: F401 +from flytekitplugins.omegaconf.listconfig_transformer import ListConfigTransformer # noqa: F401 diff --git a/plugins/flytekit-hydra/flytekitplugins/hydra/config.py b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/config.py similarity index 100% rename from plugins/flytekit-hydra/flytekitplugins/hydra/config.py rename to plugins/flytekit-omegaconf/flytekitplugins/omegaconf/config.py diff --git a/plugins/flytekit-hydra/flytekitplugins/hydra/dictconfig_transformer.py b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/dictconfig_transformer.py similarity index 97% rename from plugins/flytekit-hydra/flytekitplugins/hydra/dictconfig_transformer.py rename to plugins/flytekit-omegaconf/flytekitplugins/omegaconf/dictconfig_transformer.py index 88981b22fa..faf017687a 100644 --- a/plugins/flytekit-hydra/flytekitplugins/hydra/dictconfig_transformer.py +++ b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/dictconfig_transformer.py @@ -8,9 +8,9 @@ import flatten_dict import omegaconf from flyteidl.core.literals_pb2 import Literal as PB_Literal -from flytekitplugins.hydra.config import OmegaConfTransformerMode, SharedConfig -from flytekitplugins.hydra.flytekit_patch import iterate_get_transformers -from flytekitplugins.hydra.type_information import extract_node_type +from flytekitplugins.omegaconf.config import OmegaConfTransformerMode, SharedConfig +from flytekitplugins.omegaconf.flytekit_patch import iterate_get_transformers +from flytekitplugins.omegaconf.type_information import extract_node_type from google.protobuf.json_format import MessageToDict, ParseDict from google.protobuf.struct_pb2 import Struct from omegaconf import DictConfig, OmegaConf diff --git a/plugins/flytekit-hydra/flytekitplugins/hydra/extended_enum_transformer.py b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/extended_enum_transformer.py similarity index 100% rename from plugins/flytekit-hydra/flytekitplugins/hydra/extended_enum_transformer.py rename to plugins/flytekit-omegaconf/flytekitplugins/omegaconf/extended_enum_transformer.py diff --git a/plugins/flytekit-hydra/flytekitplugins/hydra/flytekit_patch.py b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/flytekit_patch.py similarity index 100% rename from plugins/flytekit-hydra/flytekitplugins/hydra/flytekit_patch.py rename to plugins/flytekit-omegaconf/flytekitplugins/omegaconf/flytekit_patch.py diff --git a/plugins/flytekit-hydra/flytekitplugins/hydra/listconfig_transformer.py b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/listconfig_transformer.py similarity index 96% rename from plugins/flytekit-hydra/flytekitplugins/hydra/listconfig_transformer.py rename to plugins/flytekit-omegaconf/flytekitplugins/omegaconf/listconfig_transformer.py index 48a835f75a..0d5e327fc5 100644 --- a/plugins/flytekit-hydra/flytekitplugins/hydra/listconfig_transformer.py +++ b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/listconfig_transformer.py @@ -5,9 +5,9 @@ import omegaconf from flyteidl.core.literals_pb2 import Literal as PB_Literal -from flytekitplugins.hydra.config import OmegaConfTransformerMode, SharedConfig -from flytekitplugins.hydra.flytekit_patch import iterate_get_transformers -from flytekitplugins.hydra.type_information import extract_node_type +from flytekitplugins.omegaconf.config import OmegaConfTransformerMode, SharedConfig +from flytekitplugins.omegaconf.flytekit_patch import iterate_get_transformers +from flytekitplugins.omegaconf.type_information import extract_node_type from google.protobuf.json_format import MessageToDict, ParseDict from google.protobuf.struct_pb2 import Struct from omegaconf import ListConfig, OmegaConf diff --git a/plugins/flytekit-hydra/flytekitplugins/hydra/type_information.py b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/type_information.py similarity index 97% rename from plugins/flytekit-hydra/flytekitplugins/hydra/type_information.py rename to plugins/flytekit-omegaconf/flytekitplugins/omegaconf/type_information.py index ab3a5eacfb..85df9bc64b 100644 --- a/plugins/flytekit-hydra/flytekitplugins/hydra/type_information.py +++ b/plugins/flytekit-omegaconf/flytekitplugins/omegaconf/type_information.py @@ -69,7 +69,7 @@ def extract_node_type( if key not in python_val_annotations: raise ValueError( f"Key '{key}' not found in type annotations {python_val_annotations}. " - "Check your hydra config for invalid subtrees not covered by your structured config." + "Check your DictConfig object for invalid subtrees not covered by your structured config." ) if typing.get_origin(python_val_annotations[key]) is not None: diff --git a/plugins/flytekit-hydra/setup.py b/plugins/flytekit-omegaconf/setup.py similarity index 87% rename from plugins/flytekit-hydra/setup.py rename to plugins/flytekit-omegaconf/setup.py index b60982f94a..200bf12341 100644 --- a/plugins/flytekit-hydra/setup.py +++ b/plugins/flytekit-omegaconf/setup.py @@ -1,10 +1,10 @@ from setuptools import setup -PLUGIN_NAME = "hydra" +PLUGIN_NAME = "omegaconf" microlib_name = f"flytekitplugins-{PLUGIN_NAME}" -plugin_requires = ["flytekit>=1.10.0,<2.0.0", "flatten-dict", "hydra-core>=1.2.0"] +plugin_requires = ["flytekit>=1.10.0,<2.0.0", "flatten-dict", "omegaconf>=2.3.0"] __version__ = "0.0.0+develop" @@ -13,8 +13,8 @@ version=__version__, author="flyteorg", author_email="admin@flyte.org", - description="Hydra plugin for Flytekit", - url="https://github.com/flyteorg/flytekit/tree/master/plugins/flytekit-hydra", + description="OmegaConf plugin for Flytekit", + url="https://github.com/flyteorg/flytekit/tree/master/plugins/flytekit-omegaconf", long_description=open("README.md").read(), long_description_content_type="text/markdown", namespace_packages=["flytekitplugins"], diff --git a/plugins/flytekit-hydra/tests/__init__.py b/plugins/flytekit-omegaconf/tests/__init__.py similarity index 100% rename from plugins/flytekit-hydra/tests/__init__.py rename to plugins/flytekit-omegaconf/tests/__init__.py diff --git a/plugins/flytekit-hydra/tests/conftest.py b/plugins/flytekit-omegaconf/tests/conftest.py similarity index 100% rename from plugins/flytekit-hydra/tests/conftest.py rename to plugins/flytekit-omegaconf/tests/conftest.py diff --git a/plugins/flytekit-hydra/tests/test_extract_node_type.py b/plugins/flytekit-omegaconf/tests/test_extract_node_type.py similarity index 97% rename from plugins/flytekit-hydra/tests/test_extract_node_type.py rename to plugins/flytekit-omegaconf/tests/test_extract_node_type.py index 90e972989a..71aa7fabdb 100644 --- a/plugins/flytekit-hydra/tests/test_extract_node_type.py +++ b/plugins/flytekit-omegaconf/tests/test_extract_node_type.py @@ -2,7 +2,7 @@ import typing as t import pytest -from flytekitplugins.hydra.type_information import extract_node_type +from flytekitplugins.omegaconf.type_information import extract_node_type from omegaconf import DictConfig, ListConfig, OmegaConf from tests.conftest import ExampleConfig, ExampleConfigWithNonAnnotatedSubtree diff --git a/plugins/flytekit-hydra/tests/test_objects.py b/plugins/flytekit-omegaconf/tests/test_objects.py similarity index 100% rename from plugins/flytekit-hydra/tests/test_objects.py rename to plugins/flytekit-omegaconf/tests/test_objects.py diff --git a/plugins/flytekit-hydra/tests/test_plugin.py b/plugins/flytekit-omegaconf/tests/test_plugin.py similarity index 94% rename from plugins/flytekit-hydra/tests/test_plugin.py rename to plugins/flytekit-omegaconf/tests/test_plugin.py index 5ee3062b48..4e5dded023 100644 --- a/plugins/flytekit-hydra/tests/test_plugin.py +++ b/plugins/flytekit-omegaconf/tests/test_plugin.py @@ -1,10 +1,10 @@ from typing import Any -import flytekitplugins.hydra # noqa +import flytekitplugins.omegaconf # noqa import pytest from flyteidl.core.literals_pb2 import Literal, Scalar -from flytekitplugins.hydra import DictConfigTransformer -from flytekitplugins.hydra.config import OmegaConfTransformerMode, SharedConfig +from flytekitplugins.omegaconf import DictConfigTransformer +from flytekitplugins.omegaconf.config import OmegaConfTransformerMode, SharedConfig from google.protobuf.struct_pb2 import Struct from omegaconf import MISSING, DictConfig, ListConfig, OmegaConf, ValidationError from pytest import mark, param @@ -65,9 +65,9 @@ def test_cfg_roundtrip(obj: Any) -> None: transformer = TypeEngine.get_transformer(type(obj)) assert ( - isinstance(transformer, flytekitplugins.hydra.dictconfig_transformer.DictConfigTransformer) - or isinstance(transformer, flytekitplugins.hydra.listconfig_transformer.ListConfigTransformer) - or isinstance(transformer, flytekitplugins.hydra.extended_enum_transformer.GenericEnumTransformer) + isinstance(transformer, flytekitplugins.omegaconf.dictconfig_transformer.DictConfigTransformer) + or isinstance(transformer, flytekitplugins.omegaconf.listconfig_transformer.ListConfigTransformer) + or isinstance(transformer, flytekitplugins.omegaconf.extended_enum_transformer.GenericEnumTransformer) ) literal = transformer.to_literal(ctx, obj, type(obj), expected)