Skip to content

Commit

Permalink
ruff ruff
Browse files Browse the repository at this point in the history
Signed-off-by: mg515 <[email protected]>
  • Loading branch information
mg515 committed Mar 28, 2024
1 parent f65136a commit 76297da
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions plugins/flytekit-hydra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ The transformer can be set to one of three modes:

`Dataclass` - This mode should be used with a StructuredConfig and will reconstruct the config from the matching dataclass
during deserialisation in order to make typing information from the dataclass and continued validation thereof available.
This requires the dataclass definition to be available via python import in the Flyte execution environment in which
This requires the dataclass definition to be available via python import in the Flyte execution environment in which
objects are (de-)serialised.

`DictConfig` - This mode will deserialize the config into a DictConfig object. In particular, dataclasses are translated
into DictConfig objects and only primitive types are being checked. The definition of underlying dataclasses for
into DictConfig objects and only primitive types are being checked. The definition of underlying dataclasses for
structured configs is only required during the initial serialization for this mode.

`Auto` - This mode will try to deserialize according to the Dataclass mode and fall back to the DictConfig mode if the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
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 google.protobuf.json_format import MessageToDict, ParseDict
from google.protobuf.struct_pb2 import Struct
from omegaconf import DictConfig, OmegaConf

from flytekit import FlyteContext
from flytekit.core.type_engine import TypeTransformerFailedError
from flytekit.extend import TypeEngine, TypeTransformer
from flytekit.models.literals import Literal, Scalar
from flytekit.models.types import LiteralType, SimpleType
from google.protobuf.json_format import MessageToDict, ParseDict
from google.protobuf.struct_pb2 import Struct
from omegaconf import DictConfig, OmegaConf

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

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import dataclasses
import inspect
import logging
from typing import get_args, Type
from typing import Type, get_args

from flytekit.core.type_engine import is_annotated, TypeEngine, TypeTransformer
from flytekit.core.type_engine import TypeEngine, TypeTransformer, is_annotated

logger = logging.getLogger()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

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 google.protobuf.json_format import MessageToDict, ParseDict
from google.protobuf.struct_pb2 import Struct
from omegaconf import ListConfig, OmegaConf

from flytekit import FlyteContext
from flytekit.core.type_engine import TypeTransformerFailedError
from flytekit.extend import TypeEngine, TypeTransformer
from flytekit.models.literals import Literal, Primitive, Scalar
from flytekit.models.types import LiteralType, SimpleType
from google.protobuf.json_format import MessageToDict, ParseDict
from google.protobuf.struct_pb2 import Struct
from omegaconf import ListConfig, OmegaConf

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

T = TypeVar("T")
logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def extract_node_type(

logger.debug(
f"Inferring type information directly from runtime object {python_val[key]} for serialisation purposes. "
"For more stable type resolution and serialisation provide explict type hints."
"For more stable type resolution and serialisation provide explicit type hints."
)
node_type = type(python_val[key])
type_name = f"{node_type.__module__}.{node_type.__name__}"
Expand Down
4 changes: 2 additions & 2 deletions plugins/flytekit-hydra/tests/test_extract_node_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import typing as t

import pytest
from flytekitplugins.hydra.type_information import extract_node_type
from omegaconf import DictConfig, ListConfig, OmegaConf

from flytekitplugins.hydra.type_information import extract_node_type
from tests.conftest import ExampleConfig, ExampleConfigWithNonAnnotatedSubtree


Expand Down Expand Up @@ -66,7 +66,7 @@ def test_raises_nonannotated_subtree(self) -> None:
extract_node_type(python_val, "unnanotated_key")

def test_single_unnanotated_node(self) -> None:
"""Test that inferring a fully unnanotated node works by infering types from runtime values."""
"""Test that inferring a fully unnanotated node works by inferring types from runtime values."""

python_val = OmegaConf.create({"unannotated_dictconfig_key": {"unnanotated_int_key": 2}})
node_type, type_name = extract_node_type(python_val, key="unannotated_dictconfig_key")
Expand Down

0 comments on commit 76297da

Please sign in to comment.