jobs.SweepConfig

jobs.SweepConfig(
    config_parameters=list(),
    file_parameters=list(),
    compound_parameters=list(),
    strategy=None,
)

Configuration for parameter sweep expansion.

Supports three types of sweep parameters: - config_parameters: Values injected into Jinja templates (cartesian product) - file_parameters: Different input data files (cartesian product) - compound_parameters: Groups of parameters that vary together (zipped internally, cartesian with other parameters)

Attributes

Name Type Description
config_parameters list[ConfigSweepParameter] Parameters injected into Jinja templates.
file_parameters list[FileSweepParameter] File paths to sweep over in file_mappings.
compound_parameters list[CompoundSweepParameter] Groups of parameters that should co-vary.
strategy SweepStrategy | None Expansion strategy (default: CartesianStrategy).
parameters list[ConfigSweepParameter] Deprecated alias for config_parameters (backward compat).

Examples

>>> # Default cartesian (grid search) strategy
>>> config = SweepConfig(
...     config_parameters=[
...         ConfigSweepParameter(name="a", values=[1, 2, 3]),
...     ],
... )
>>> # With compound parameters (files that should stay together)
>>> config = SweepConfig(
...     compound_parameters=[
...         CompoundSweepParameter(
...             name="climate_scenario",
...             parameters=[
...                 FileSweepParameter(name="temp", paths=["t_ssp126.jshd", "t_ssp245.jshd"]),
...                 FileSweepParameter(name="precip", paths=["p_ssp126.jshd", "p_ssp245.jshd"]),
...             ],
...             labels=["ssp126", "ssp245"],
...         ),
...     ],
... )
>>> # With explicit strategy
>>> from joshpy.strategies import OptunaStrategy
>>> config = SweepConfig(
...     config_parameters=[
...         ConfigSweepParameter(name="a", values=[1, 2, 3]),
...     ],
...     strategy=OptunaStrategy(n_trials=50),
... )

Methods

Name Description
expand Generate parameter combinations using the configured strategy.
from_dict Create from dict.
to_dict Convert to dict for serialization.

expand

jobs.SweepConfig.expand()

Generate parameter combinations using the configured strategy.

Returns a List of dicts, each representing one parameter combination.

For config parameters: {“param_name”: value} For file parameters: {“file_name”: {“path”: Path, “label”: str}} For compound parameters: {“group_name”: label, “inner_param”: value, …}

For example, with config param A=[1,2] and file param F=[a.jshd, b.jshd]: [{“A”: 1, “F”: {“path”: Path(“a.jshd”), “label”: “a”}}, {“A”: 1, “F”: {“path”: Path(“b.jshd”), “label”: “b”}}, {“A”: 2, “F”: {“path”: Path(“a.jshd”), “label”: “a”}}, {“A”: 2, “F”: {“path”: Path(“b.jshd”), “label”: “b”}}]

Raises

Name Type Description
RuntimeError If strategy is adaptive (use run_adaptive_sweep() instead).

from_dict

jobs.SweepConfig.from_dict(data)

Create from dict.

Supports both new-style (config_parameters, file_parameters, compound_parameters) and legacy (parameters) formats.

to_dict

jobs.SweepConfig.to_dict()

Convert to dict for serialization.