zen_garden.cli.zen_garden_cli¶
Functions
Build the command-line argument parser for ZEN-garden. |
|
Entry point for the zen-garden command-line interface. |
|
|
Resolves the job index when running ZEN-garden from the command line. |
- zen_garden.cli.zen_garden_cli.build_parser() ArgumentParser¶
Build the command-line argument parser for ZEN-garden.
This function defines all supported command-line options for running ZEN-garden. The parser handles configuration file selection, dataset and output directory overrides, and job indexing for array or batch execution.
- Command Line Flags:
- –config (str, optional):
Path to a Python or JSON configuration file. If not provided, the configuration is read from the current working directory. Defaults to “./config.json”.
- –dataset (str, optional):
Path to the dataset directory. Overrides
config.analysis.datasetin the configuration file.- –folder_output (str, optional):
Path to the output directory. Overrides output-related settings in the configuration file. If not specified, output is written to the current working directory.
- –job_index (str, optional):
Comma-separated list of scenario or job indices to execute. If not provided, the value is read from the environment variable specified by
--job_index_var.- –job_index_var (str, optional):
Name of the environment variable containing the job index. Defaults to
SLURM_ARRAY_TASK_ID.
- Returns:
An argument parser configured for the ZEN-Garden command-line interface.
- Return type:
argparse.ArgumentParser
- zen_garden.cli.zen_garden_cli.create_zen_garden_cli()¶
Entry point for the zen-garden command-line interface.
This function creates the command-line interface for running ZEN-garden. It first sets up an argument parser; extracts the job index (either from the input flax directly or from an environment variable), and then calls the
zen_garden.run()function.The
[project.scripts]section of the pyproject.toml declares that this function will be called whenever a user enterszen-gardeninto the command prompt.- Command Line Flags:
- –config (str, optional):
Path to a Python or JSON configuration file. If not provided, the configuration is read from the current working directory.
- –dataset (str, optional):
Path to the dataset directory. Overrides
config.analysis.datasetin the configuration file.- –folder_output (str, optional):
Path to the output directory. Overrides output-related settings in the configuration file. If not specified, output is written to the current working directory.
- –job_index (str, optional):
Comma-separated list of scenario or job indices to execute. If not provided, the value is read from the environment variable specified by
--job_index_var.- –job_index_var (str, optional):
Name of the environment variable containing the job index. Defaults to
SLURM_ARRAY_TASK_ID.
- Returns:
None
Examples
Basic usage in a command line prompt:
>>> zen-garden --config=".\config.json" --dataset="1_base_case"
- zen_garden.cli.zen_garden_cli.resolve_job_index(job_index: str, job_index_var: str) list[int]¶
Resolves the job index when running ZEN-garden from the command line.
If the job index is directly specified using the
job_indexcommand-line flag, those values are used. Otherwise, the job index is extracted from the environment variable specified by thejob_index_varcommand-line flag. If neither is defined,Noneis returned.- Parameters:
job_index (str) – Value of the
job_indexcommand-line flag provided by the user.job_index_var (str) – Value of the
job_index_varcommand-line flag provided by the user.
- Returns:
- List of job indices to run in the current instance of
ZEN-garden, or
Noneif no job index is specified.
- Return type:
list[int] | None