Skip to content

Commit

Permalink
minor style improvements
Browse files Browse the repository at this point in the history
Signed-off-by: mg515 <[email protected]>
  • Loading branch information
mg515 committed May 12, 2024
1 parent 4fdb7e5 commit 08f9a80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class OmegaConfTransformerMode(Enum):
Operation Mode indicating whether a (potentially unannotated) DictConfig object or a structured config using the
underlying dataclass is returned.
Note: We define a single shared configs across all transformers as recursive calls should refer to the same config
Note: We define a single shared config across all transformers as recursive calls should refer to the same config
Note: The latter requires the use of structured configs.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
NoneType = type(None)


def is_flatable(d: DictConfig) -> bool:
def is_flattenable(d: DictConfig) -> bool:
"""Check if a DictConfig can be properly flattened and unflattened, i.e. keys do not contain dots."""
return all(
isinstance(k, str) # keys are strings ...
and "." not in k # ... and do not contain dots
and (
OmegaConf.is_missing(d, k) # values are either MISSING ...
or not isinstance(d[k], DictConfig) # ... not nested Dictionaries ...
or is_flatable(d[k])
or is_flattenable(d[k])
) # or flatable themselves
for k in d.keys()
)
Expand Down Expand Up @@ -76,7 +76,7 @@ def to_literal(self, ctx: FlyteContext, python_val: T, python_type: Type[T], exp
# type_engine.py#L1222
if not isinstance(python_val, DictConfig):
raise ValueError(f"Invalid type {type(python_val)}, can only serialise DictConfigs")
if not is_flatable(python_val):
if not is_flattenable(python_val):
raise ValueError(
f"{python_val} cannot be flattened as it contains non-string keys or keys containing dots."
)
Expand Down

0 comments on commit 08f9a80

Please sign in to comment.