Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pace/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,21 @@ def from_dict(cls, kwargs: Dict[str, Any]) -> "DriverConfig":
"as it is determined based on top-level configuration"
)

# TODO - After pyFV3 PR #88, replace dycore dacite cmd with:
# kwargs["dycore_config"] = DynamicalCoreConfig.from_dict(
# kwargs.get("dycore_config", {})
# )
dycore_dacite_config = dacite.Config(
strict=True,
type_hooks={
Tuple[int, int]: lambda x: tuple(x),
Tuple[str, ...]: lambda x: tuple(x) if x is not None else None,
},
)
kwargs["dycore_config"] = dacite.from_dict(
data_class=DynamicalCoreConfig,
data=kwargs.get("dycore_config", {}),
config=dacite.Config(strict=True),
config=dycore_dacite_config,
)

if isinstance(kwargs["physics_config"], dict):
Expand Down
4 changes: 3 additions & 1 deletion tests/main/fv3core/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def assert_types_match(classes):
types = collections.defaultdict(set)
for cls in classes:
for name, field in cls.__dataclass_fields__.items():
types[name].add(field.type)
# Get type hints in case we're using postponed evaluation of types
# Example: '<class 'bool'> instead of 'bool'
types[name].add(typing.get_type_hints(cls)[name])
for name, attr in cls.__dict__.items():
if isinstance(attr, property):
types[name].add(
Expand Down