Skip to content

Conversation

@halungge
Copy link
Contributor

@halungge halungge commented Nov 7, 2025

Adds Configuration for ICON4Py in two parts:

  • common provides a ConfigurationHandler for initialization of configuration for a @dataclass or a yaml file. This one can be used in each model component. There are two examples for this in model.atmosphere.diffusion and model.atmosphere.dycore
  • ConfigurationManger in model.driver which is supposed to be used in a model run. It reads a yaml file and initializes a ConfigurationHandler for each model registered in the model config and makes the configuration available (as dictionary) to the model.

# Conflicts:
#	model/atmosphere/diffusion/src/icon4py/model/atmosphere/diffusion/diffusion.py
#	uv.lock
@halungge halungge marked this pull request as ready for review November 18, 2025 17:42
@github-actions
Copy link

Mandatory Tests

Please make sure you run these tests via comment before you merge!

  • cscs-ci run default

Optional Tests

To run benchmarks you can use:

  • cscs-ci run benchmark-bencher

To run tests and benchmarks with the DaCe backend you can use:

  • cscs-ci run dace

To run test levels ignored by the default test suite (mostly simple datatest for static fields computations) you can use:

  • cscs-ci run extra

For more detailed information please look at CI in the EXCLAIM universe.

@halungge halungge requested a review from OngChia November 19, 2025 08:52
self._initialize_components(user_config)

# TODO (halungge): have this return a std dict to hide away omegaconf
def get(
Copy link
Contributor Author

@halungge halungge Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this return a TypeDict..

Copy link
Contributor

@OngChia OngChia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the configuration infrastructure!
It looks awesome. Currently, I have a few questions on the configuration manager.

"""

# number of dynamics substeps
ndyn_substeps: int = dataclasses.field(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In contrast to DiffusionConfig, we do not need ndyn_substeps for NonHydrostaticConfig because stencils in SolveNonhydro need the runtime changeable ndyn_substeps_var.


# from mo_nonhydrostatic_nml.f90
ndyn_substeps: int = dataclasses.field(
default=common_config.resolve_or_else("model.ndyn_substeps", 5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ndyn_substeps always have to be inherited from a outer config? Or I can do, let's say,

ndyn_substeps: int = dataclasses.field(
        default=common_config.resolve_or_else("model.run.ndyn_substeps", 5)
)

I feel that it is more suitable for ndyn_substeps to sit in the run config, because this variable controls how many substeps the driver runs the dycore.

default_reader = module.init_config()
default_reader.update(update)
else:
log.warning(f" module {module.__name__} has no `init_config` function")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we force config.py in all components has this init_config function?
Otherwise, it seems that users can have some wrong parameters in the full_model_config.yaml file and probably an error will be thrown when the granule is initialized.

def get(
self,
is_default: bool = False,
) -> oc.DictConfig:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking that whether to give users an option of returning a dictionary of config classes (run, dycore, diffusion, ...) for convenience?

f"No default configuration and no user-configuration for component {name} defined in file {self._config_file}"
)
else:
reader.update(module_config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be true in the if statement above that users have developed a component without any config parameters.
However, I am wondering that should we just throw an error here in this case where users put a config for a particular component whereas there is in config.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants