api¶
api provides the user-facing entry points that wrap the Runner in a CLI-friendly
way and expose train, evaluate, and infer as both Python functions and console scripts.
Console Scripts¶
| Command | Function | Notes |
|---|---|---|
mmtrain |
train |
Forces config.training = True. |
mmevaluate |
evaluate |
Forces config.training = False. |
mminfer |
infer |
Writes predictions to config.result_path. |
Each command parses arguments through Chanfig. The default config file is config.yaml
in the current working directory; CLI arguments override individual fields:
| Bash | |
|---|---|
mminfer defaults result_path to ./result.json and emits a RuntimeWarning if the field is not set explicitly.
Working Directory Contract¶
Before building the runner, dynamic_import appends the parent of cwd to
sys.path and imports os.path.basename(cwd) as a Python module. If config.pretrained matches a sub-directory of
cwd, that sub-directory is also appended and imported.
This is how custom datasets, models, and runners register themselves before the runner is built. The working
directory must therefore be importable as a Python package (i.e. contain an __init__.py).
Programmatic Usage¶
The same entry points are usable from Python:
train / evaluate / infer always run Config.parse on the provided config, so config.yaml (when present) and
CLI overrides are still applied. Pass config=None to start from an empty Config and rely entirely on the YAML
file plus CLI arguments.
To bypass the CLI orchestration entirely (no banner, no dl.debug context, no NNI integration),
build the runner directly through RUNNERS — see the runner
page.
Optional Flags¶
debug=true— wrap the run indl.debugfor verbose tracing.nni=true— read hyperparameters fromnni.get_next_parameter()and merge them into the config; requires thennipackage.
Result Aggregation¶
multimolecule.api.stat walks an experiment root, parses each run’s best.json and trainer.yaml, and produces a
CSV summary. Run as a script:
| Bash | |
|---|---|