micm_nlp.training.run_output¶
A run’s output directory, and everything the trainer writes into it that is not a metric or a prediction.
RunOutput is constructed by the trainer before the HuggingFace arguments
exist (they need the directory) and holds: the directory, the static columns
stamped onto every metrics row, the config snapshot (config.yml – the
config as the framework resolved it, written before anything non-serialisable
can reach it), info.json (environment, paths, the values the trainer
resolved, the wandb identity, start/finish) and the model / wandb
symlinks. Metrics and predictions files are written by
micm_nlp.evals.results, into RunOutput.file().
The config is read-only for the trainer: what the run did is recorded here, never written back into the config.
Attributes¶
Classes¶
One run's output directory. |
Functions¶
|
What the run ran on: every |
|
The directory a run writes into. |
|
This package's own commit, |
|
Identity and location of a wandb run, or |
|
Save a config as plain YAML (enums as strings) into |
|
Merge |
Module Contents¶
- class micm_nlp.training.run_output.RunOutput(config, model)¶
One run’s output directory.
- Parameters:
config – the run’s config; its
outputblock (if any) supplies the directory, the file prefix, the config file name and static columns.model – the
MODEL– itsnamenames a solo run’s directory, itsuuid4is stamped on every row, itspath(when the mode has a checkpoint dir) is linked asmodel.
- file(name: str) pathlib.Path¶
The path of one of this run’s files, with the output prefix applied.
- link(name: str, target: str | pathlib.Path | None) pathlib.Path | None¶
A symlink
dir/name -> target(absolute), so every artefact of the run is reachable from its directory.A target that does not exist yet still gets a link – the checkpoint directory appears only when the trainer saves. A link that already points at
targetis left alone; one that points elsewhere is replaced.Noneis a no-op.
- note_wandb(run) None¶
Record the wandb run’s id, url and local dir, and link the dir.
- record(kind: str, event: str, rows: list[dict[str, Any]]) None¶
Keep the rows of one written file, so the run is readable in memory.
Called by
save_metrics()andsave_predictions()as they write, which is why nothing inTRAINERhas to collect results: whatever reaches disk is here, under the same event name, in the same row shape the CSV holds. That equality is the point – it is what lets a futureRunOutput.load(dir)read a finished run back into the same attributes rather than a second, parallel shape.- Parameters:
kind –
'results'for a metrics file,'predictions'for a predictions file – the two kinds a run writes.event – the event name the file is named for (
test_after_train).
- resolved(**values) None¶
Record the values the trainer derived from the config (the seed it drew, the prefixed
metric_for_best_model,fp16by device) ininfo.json– underresolved, or<prefix>resolvedfor a prefixed trainer (aseparate_testconfig, or a runner-set prefix), so two never overwrite each other – and stampseedas a column unless the config pinned one (aseparate_testtrainer stamps the seed its own process used; it inherits a pinned one throughoutput.columns).
- write_run_info(**sections) pathlib.Path¶
Merge
sectionsinto this run’sinfo.json; see the module function.The merged result is read back into
info, so the attribute always equals the file rather than a parallel accumulation of the same sections.
- columns: dict[str, Any]¶
- dir¶
- info: dict[str, Any]¶
- predictions: dict[str, list[dict[str, Any]]]¶
- prefix¶
- results: dict[str, list[dict[str, Any]]]¶
- micm_nlp.training.run_output.environment_info() dict[str, Any]¶
What the run ran on: every
SLURM*variable, host, interpreter, visible GPUs, and the versions of the packages that decide numerics.The scheduler block is one glob rather than a hand-kept list, so a variable the scheduler adds tomorrow is recorded without a code change.
- micm_nlp.training.run_output.output_dir_for(config, model_name: str) str¶
The directory a run writes into.
output.dirwins when set – the group runner puts the run there. Otherwise the run belongs to no group and lands underruns/units/{model_name}, wheremodel_nameis the generated name (uuid first), unique and equal to the wandb run name.
- micm_nlp.training.run_output.package_commit() str | None¶
This package’s own commit,
-dirtywhen its tree has uncommitted changes;Nonewhen it is an installed copy rather than a checkout.The version alone does not identify the code: an editable install follows a working tree that moves between releases, which is how a result stops being reproducible.
- micm_nlp.training.run_output.wandb_info(run) dict[str, Any] | None¶
Identity and location of a wandb run, or
Nonewithout one.diris the run directory (the parent ofrun.dir, which is itsfiles/);urlisNoneoffline, where some wandb versions raise on the property.
- micm_nlp.training.run_output.write_config(dir_: str | pathlib.Path, config, filename: str = CONFIG_FILE) pathlib.Path¶
Save a config as plain YAML (enums as strings) into
dir_, creating it.
- micm_nlp.training.run_output.write_run_info(dir_: str | pathlib.Path, **sections) pathlib.Path¶
Merge
sectionsinto<dir_>/info.json(read-modify-write).Dict-valued sections merge one level deep;
startedis kept from the first write; everything else is latest-wins. Values must be JSON-serialisable.
- micm_nlp.training.run_output.CONFIG_FILE = 'config.yml'¶
- micm_nlp.training.run_output.RUN_INFO_FILE = 'info.json'¶
- micm_nlp.training.run_output.TEST_CONFIG_FILE = 'test_config.yml'¶