refactor: generate train and serve CLIs from config-backed option specs
- Add astrai/config/cli.py: OptSpec tables plus apply_specs infer click types and defaults from config fields, covering Optional[X], Union[X, None], PEP 604 X | None, stringified PEP 563 annotations, bool flag pairs, and repeatable list options - Move GroupedCommand/GroupedOption and the three-layer YAML merge (option defaults < YAML < explicit CLI) into the config package, adding unknown-key warning and mapping validation - Replace ~420 lines of hand-written @opt decorators in scripts/tools/train.py with a 66-entry spec table; option names, defaults, flag styles, and YAML semantics verified unchanged - Migrate scripts/tools/server.py to the same mechanism with its section binding, integer coercion, and dtype validation preserved locally - Add tests/config/test_cli.py covering type inference across annotation styles, default overrides, flag pairs, merge precedence, scientific notation, and help ordering
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
from astrai.config.cli import (
|
||||
GroupedCommand,
|
||||
GroupedOption,
|
||||
OptSpec,
|
||||
apply_specs,
|
||||
merge_yaml_into_kwargs,
|
||||
opt,
|
||||
)
|
||||
from astrai.config.model_config import (
|
||||
AutoRegressiveLMConfig,
|
||||
BaseModelConfig,
|
||||
@@ -22,4 +30,10 @@ __all__ = [
|
||||
"OutputConfig",
|
||||
"PipelineConfig",
|
||||
"ProcessingConfig",
|
||||
"GroupedCommand",
|
||||
"GroupedOption",
|
||||
"OptSpec",
|
||||
"apply_specs",
|
||||
"merge_yaml_into_kwargs",
|
||||
"opt",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user