runtraj.ProjectConfig#

class runtraj.ProjectConfig(*, mets: dict[str, dict[str, typing.Any] | str]=<factory>, models: dict[str, dict[str, typing.Any] | None]=<factory>, stages: dict[str, dict[str, typing.Any]]=<factory>, variants: dict[str, dict[str, typing.Any] | None]=<factory>, execution: runtraj.execution.config.ExecutionConfig = <factory>, output: str = 'output') → None[source]#

A project’s configuration, as read from config.yaml.

The file is blocks. mets names the meteorology, models the transport models, stages what is made from each simulation’s results, and variants what runs. A model’s or a stage’s block holds its settings, checked by its own config class: the defaults of every variant that uses it. Each variant names a met and a model, when there are several, and overrides some of the defaults; only the declared variants run. No setting sits at the top level: one written there is refused with a message that names its block. An unknown key is an error that names the nearest setting.

Parameters#

Parameter

Description

Default

mets

Meteorology by name, such as hrrr: the folder of its files, or a mapping of its settings. At least one is required. Each is checked by the met config of the transport model that reads it (runtraj.models.hysplit.MetConfig for HYSPLIT).

{}

models

Transport models by name, each a block of its settings: the defaults of every variant that runs it. A block named hysplit is that built-in model. Any other model class gets a block of any name that gives its import path as class, such as class: mypkg.models.MyModel. A model has one block. Left out, the project runs HYSPLIT with its defaults.

{'hysplit': {}}

stages

What is made from each simulation’s results after the transport model runs, by name, each a block that gives the stage’s import path as class and then its settings. A block is named for its stage: PYSTILT’s footprint, for example, is the block footprint with class: stilt.footprint.FootprintStage. A stage runs for every variant, unless the variant sets it to null. Left out, the project makes particles only.

{}

variants

Variants by name, each a set of overrides of the defaults. A variant’s own keys are met (needed with several mets unless the variant has a met’s name), model (the name of its models block, needed with several), realizations (run N times, realization k with seed + k, as one ensemble), and stages (a stage’s settings to change, by the stage’s name, or null for a variant without it). Every other key is a setting of its model. Variants with the same transport settings share one transport model run and differ in what their stages make from it. At least one is required: hrrr: {} runs the defaults.

{}

execution

Where the releases run and with what resources, such as backend: slurm and its options.

ExecutionConfig(backend='local', local=LocalConfig(cpus=1, fetch=True), slurm=SlurmCo...

output

Directory the results go to, relative to the project directory unless absolute. A URL such as s3://bucket/output puts it on an object store. Several projects can name the same directory and share runs.

'output'

Methods#

from_yaml(path)

Load a project config from a YAML file.

met_config(name[, model])

Return the met called name, checked by the met config of the transport model that reads it.

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

resolve([directory])

Return one Variant per declared variant, in declared order.

to_yaml([path])

Return the config as YAML, and write it to path when given.