Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added a check for the number of ensemble members, as the code currently supports only one [!13](https://github.com/dmidk/sunflow/pull/13), @KristianHMoller

## [v1.1.0]

### Added
Expand Down
2 changes: 2 additions & 0 deletions sunflow/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
validate_clearsky_shapes,
validate_config,
validate_data_shape,
validate_nowcast_config,
validate_run_mode,
verify_environment_variables,
)
Expand Down Expand Up @@ -407,6 +408,7 @@ def cli() -> None:

validate_run_mode(run_mode, dataset_name)
validate_config(config, dataset_name)
validate_nowcast_config(nowcast_config)
verify_environment_variables(run_mode, dataset_name)

# Determine the time steps to run
Expand Down
23 changes: 23 additions & 0 deletions sunflow/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import xarray as xr
from loguru import logger

from .config import NowcastConfig


class MissingClearskyDataError(RuntimeError):
pass
Expand Down Expand Up @@ -44,6 +46,27 @@ def validate_config(config: dict[str, Any], dataset_name: str) -> None:
sys.exit(1)


def validate_nowcast_config(nowcast_config: NowcastConfig) -> None:
"""Validate that the options selected for the nowcast config are valid.

Checks the nowcast config created from imported environment variables.
Exits immediately for invalid choices.

Args:
nowcast_config: Instance of the NowcastConfig class
loaded from environment variables in config.py.

Raises:
SystemExit: If any invalid choice is detected.
"""
if nowcast_config.ens_members != 1:
logger.error(
f"Invalid nowcast configuration: Currently, only ens_members=1 is supported. "
f"Current value: {nowcast_config.ens_members}. Exiting.\n"
)
sys.exit(1)


def validate_run_mode(run_mode: str, dataset_name: str) -> None:
"""Validate that the run mode is compatible with the dataset.

Expand Down
Loading