Skip to content

Commit

Permalink
rename plugin from flytekit-hydra into flytekit-omegaconf
Browse files Browse the repository at this point in the history
  • Loading branch information
mg515 committed Apr 4, 2024
1 parent 20e2281 commit 4b036d7
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 28 deletions.
3 changes: 0 additions & 3 deletions plugins/flytekit-hydra/flytekitplugins/hydra/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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"],
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4b036d7

Please sign in to comment.