geoprior.cli.config#
Shared CLI configuration helpers.
This module centralises the parser options and runtime helpers that repeat across GeoPrior CLI commands. The goal is to keep command modules small, consistent, and easy to maintain.
Scope#
This module is intentionally limited to:
repeated parser arguments such as
--configand--setlight argument aliases and normalisation
config installation and runtime override persistence
small path utilities used by many commands
It does not own command-specific business logic. Each command keeps its own artifact resolution and domain-specific validation.
Examples
Build a parser with shared arguments:
import argparse
from geoprior.cli._config import (
add_city_arg,
add_config_args,
add_outdir_arg,
add_results_dir_arg,
)
p = argparse.ArgumentParser()
add_config_args(p)
add_city_arg(p)
add_results_dir_arg(p)
add_outdir_arg(p)
Apply config installation and runtime overrides:
cfg = bootstrap_runtime_config(
args,
field_map={
"city": "CITY_NAME",
"model": "MODEL_NAME",
"results_dir": "RESULTS_DIR",
},
)
The returned cfg is the effective config dictionary after optional
config installation and any --set KEY=VALUE overrides.
Functions
|
Add one or repeated |
|
Add shared config installation and override arguments. |
|
Add a manifest path argument. |
|
Add |
|
Add output directory argument. |
|
Add a reusable output format argument. |
|
Add an output stem argument for multi-file commands. |
|
Add results directory argument with a root alias. |
|
Add a reusable dataset split argument. |
|
Add |
|
Add |
|
Add external validation CSV argument. |
|
Map parsed argument fields to config keys. |
|
Install config, apply overrides, and return effective cfg. |
|
Create and return an output directory path. |
|
Return the newest matching directory under |
|
Install a user |
|
Parse a scalar or container value from |
|
Parse repeated |
|
Persist effective config to |
- geoprior.cli.config.parse_override_value(raw)[source]#
Parse a scalar or container value from
--set.- Parameters:
raw (
str) – Raw string value from the CLI.- Returns:
Parsed Python object when possible, otherwise the stripped string.
- Return type:
Any
Notes
The parsing order is conservative:
case-insensitive booleans and
noneinteger / float literals
ast.literal_evalfor lists, tuples, dicts, and quoted textfallback to the stripped input string
- geoprior.cli.config.install_user_config(config_path, *, config_root='nat.com')[source]#
Install a user
config.pyinto the active config root.
- geoprior.cli.config.persist_runtime_overrides(overrides=None, *, config_root='nat.com', refresh_fn=None)[source]#
Persist effective config to
config.json.- Parameters:
- Return type:
- geoprior.cli.config.args_to_config_overrides(args, *, field_map=None)[source]#
Map parsed argument fields to config keys.
- Parameters:
args (
argparse.Namespace) – Parsed CLI namespace.field_map (
dict[str,str]orNone) – Mapping from argument field name to config key.
- Returns:
Override dictionary combining
--setitems and selected explicit CLI fields.- Return type:
- geoprior.cli.config.bootstrap_runtime_config(args, *, field_map=None, refresh_fn=None)[source]#
Install config, apply overrides, and return effective cfg.
- geoprior.cli.config.find_latest_dir(root, *, pattern='*', must_contain=None)[source]#
Return the newest matching directory under
root.
- geoprior.cli.config.add_config_args(parser, *, include_root=True, include_set=True)[source]#
Add shared config installation and override arguments.
- Parameters:
parser (ArgumentParser)
include_root (bool)
include_set (bool)
- Return type:
- geoprior.cli.config.add_city_arg(parser, *, dest='city', default=None, required=False, action=None, help=None)[source]#
Add one or repeated
--cityarguments.- Parameters:
- Return type:
- geoprior.cli.config.add_model_arg(parser, *, dest='model', default=None, required=False, help=None)[source]#
Add
--modelargument.- Parameters:
parser (ArgumentParser)
dest (str)
default (str | None)
required (bool)
help (str | None)
- Return type:
- geoprior.cli.config.add_results_dir_arg(parser, *, dest='results_dir', default=None)[source]#
Add results directory argument with a root alias.
- Parameters:
parser (ArgumentParser)
dest (str)
default (str | None)
- Return type:
- geoprior.cli.config.add_manifest_arg(parser, *, dest='manifest', option='--manifest', help_text=None)[source]#
Add a manifest path argument.
- Parameters:
parser (ArgumentParser)
dest (str)
option (str)
help_text (str | None)
- Return type:
- geoprior.cli.config.add_stage1_dir_arg(parser)[source]#
Add
--stage1-dirargument.- Parameters:
parser (ArgumentParser)
- Return type:
- geoprior.cli.config.add_outdir_arg(parser, *, dest='outdir', default=None, required=False, help=None)[source]#
Add output directory argument.
- Parameters:
parser (ArgumentParser)
dest (str)
default (str | None)
required (bool)
help (str | None)
- Return type:
- geoprior.cli.config.add_output_format_arg(parser, *, choices=('csv', 'json', 'npz', 'parquet'), default=None)[source]#
Add a reusable output format argument.
- Parameters:
parser (ArgumentParser)
default (str | None)
- Return type:
- geoprior.cli.config.add_output_stem_arg(parser, *, default=None)[source]#
Add an output stem argument for multi-file commands.
- Parameters:
parser (ArgumentParser)
default (str | None)
- Return type:
- geoprior.cli.config.add_stage2_manifest_arg(parser)[source]#
Add
--stage2-manifestargument.- Parameters:
parser (ArgumentParser)
- Return type:
- geoprior.cli.config.add_split_arg(parser, *, default=None, choices=None)[source]#
Add a reusable dataset split argument.
- Parameters:
parser (ArgumentParser)
default (str | None)
- Return type:
- geoprior.cli.config.add_validation_csv_arg(parser, *, required=False)[source]#
Add external validation CSV argument.
- Parameters:
parser (ArgumentParser)
required (bool)
- Return type: