CLI entry points for configuration management.
Each command loads or creates a SafeSynthesizerParameters model, optionally applies
CLI overrides, and either validates, prints, or writes the result.
Functions:
| Name |
Description |
config |
Manage Safe Synthesizer configurations.
|
validate |
Validate a Safe Synthesizer configuration.
|
modify |
Modify a Safe Synthesizer configuration.
|
create |
Create a new Safe Synthesizer configuration.
|
config()
Manage Safe Synthesizer configurations.
Source code in src/nemo_safe_synthesizer/cli/config.py
| @click.group()
def config():
"""Manage Safe Synthesizer configurations."""
pass
|
validate(config_path, **kwargs)
Validate a Safe Synthesizer configuration.
Source code in src/nemo_safe_synthesizer/cli/config.py
| @config.command()
@click.option(
"--config",
"config_path",
required=True,
type=str,
help="path to a yaml config file",
)
@pydantic_options(SafeSynthesizerParameters, field_separator=CLI_NESTED_FIELD_SEPARATOR)
def validate(config_path: PathT, **kwargs):
"""Validate a Safe Synthesizer configuration."""
overrides = parse_overrides(kwargs)
my_config = merge_overrides(config_path, overrides)
click.echo(my_config.model_dump_json(indent=2))
click.echo(f"Config {config_path} is valid!", err=True)
|
modify(config_path, output, **kwargs)
Modify a Safe Synthesizer configuration.
Source code in src/nemo_safe_synthesizer/cli/config.py
| @config.command()
@click.option(
"--config",
"config_path",
required=False,
type=str,
help="path to a yaml config file",
)
@click.option("--output", required=False, default=None, help="write modified config to this path")
@pydantic_options(SafeSynthesizerParameters, field_separator=CLI_NESTED_FIELD_SEPARATOR)
def modify(config_path: PathT, output: str, **kwargs):
"""Modify a Safe Synthesizer configuration."""
overrides = parse_overrides(kwargs)
my_config = merge_overrides(config_path, overrides)
if output:
my_config.to_yaml(output)
click.echo(f"Modified config written to {output}")
else:
rich.print(f"{my_config.model_dump_json(indent=2, exclude_unset=False)}")
|
create(output, **kwargs)
Create a new Safe Synthesizer configuration.
Source code in src/nemo_safe_synthesizer/cli/config.py
| @config.command()
@click.option(
"--output",
"-o",
required=False,
default=None,
type=click.Path(exists=False, dir_okay=False, file_okay=True, resolve_path=True),
help="path to the output yaml config file",
)
@pydantic_options(SafeSynthesizerParameters, field_separator=CLI_NESTED_FIELD_SEPARATOR)
def create(output: str, **kwargs):
"""Create a new Safe Synthesizer configuration."""
overrides = parse_overrides(kwargs)
my_config = merge_overrides(None, overrides)
if output:
my_config.to_yaml(output, exclude_unset=False)
click.echo(f"config written to {output}")
else:
rich.print(f"{my_config.model_dump_json(indent=2, exclude_unset=False)}")
|