micm_nlp.path

Filesystem layout: the workspace root and the artefacts/ tree beneath it.

Two kinds of path live here. PACKAGE_DIR points inside the installed package and is read-only. Everything else hangs off the workspace — the user’s project directory — which must be set once via set_root() before any accessor is called; they raise otherwise. micm_nlp.init() does that for you:

workspace()/artefacts/{models,datasets,tokenizers,runs,wandb}

Attributes

EXAMPLE_CONFIG_PACKAGE

Where the example configs ship. Inside the package rather than downloaded, so

GROUP_RUNS

runs/groups/{group}/{name}. One directory per

PACKAGE_DIR

UNIT_RUNS

runs/units/{name}.

Functions

artefacts_dir(→ pathlib.Path)

<workspace>/artefacts — the root of everything this package writes.

available_examples(→ list[tuple[pathlib.Path, Any]])

Every config shipped in the example package.

datasets_dir(→ pathlib.Path)

artefacts/datasets — raw, preprocessed and tokenized datasets.

evals_dir(→ pathlib.Path)

artefacts/evals — legacy location, no longer written to.

example(→ pathlib.Path)

The path of one config shipped inside the package.

find_dirs_by_prefix(root_dir, dir_prefix)

Recursively find every directory under root_dir whose name starts with

get_dir_items(dir_path[, only_dirs, only_files])

List the immediate contents of a directory, non-recursively.

models_dir(→ pathlib.Path)

artefacts/models — saved checkpoints and PEFT adapters.

output_dir(→ pathlib.Path)

The directory one run writes into: config snapshot, info.json,

runs_dir(→ pathlib.Path)

artefacts/runs -- one directory per run, under units/ or

set_root(workspace)

Set the workspace root. Call once at startup.

tokenizers_dir(→ pathlib.Path)

artefacts/tokenizers — tokenizers trained by this package.

wandb_dir(→ pathlib.Path)

Parent directory for wandb's own wandb/ folder.

workspace(→ pathlib.Path)

Return the workspace root.

Module Contents

micm_nlp.path.artefacts_dir() → pathlib.Path

<workspace>/artefacts — the root of everything this package writes.

micm_nlp.path.available_examples() → list[tuple[pathlib.Path, Any]]

Every config shipped in the example package.

The package root and one level of subdirectories (groups/), sorted by path.

Returns:

(relative path, traversable) pairs. The first line above is kept short and self-contained because the API reference renders it as the summary, and a summary that stops mid-literal is a docs build warning.

micm_nlp.path.datasets_dir() → pathlib.Path

artefacts/datasets — raw, preprocessed and tokenized datasets.

micm_nlp.path.evals_dir() → pathlib.Path

artefacts/evals — legacy location, no longer written to.

Runs live under runs_dir() since 0.4.0; this function has no callers and is kept only so an existing tree stays addressable.

micm_nlp.path.example(name: str) → pathlib.Path

The path of one config shipped inside the package.

run(example('xsc_finetune.yml'))

Reading a config straight out of the installed package, rather than making run fall back to it for a name that is not on disk – one visible call is easier to explain than a second lookup rule hidden inside the pipeline. micm-nlp init-examples is still the way to get an editable copy.

Parameters:

name – the file name, with or without .yml; groups/ names work too (example('groups/xsc_tune_across_seeds.yml')).

Raises:

FileNotFoundError – naming what does ship, since the set is small and fixed – a typo should not send anyone to the documentation.

micm_nlp.path.find_dirs_by_prefix(root_dir, dir_prefix)

Recursively find every directory under root_dir whose name starts with dir_prefix.

Walks the whole tree, so cost grows with the size of root_dir — the progress bar is there because an artefacts/ tree can be large.

Parameters:
  • root_dir – directory to search under.

  • dir_prefix – prefix a directory’s name must start with.

Returns:

absolute paths as strings, in walk order.

micm_nlp.path.get_dir_items(dir_path, only_dirs=False, only_files=False)

List the immediate contents of a directory, non-recursively.

Parameters:
  • dir_path – directory to list.

  • only_dirs – return only subdirectories.

  • only_files – return only files.

Returns:

names, with a trailing / on directories. A missing dir_path yields [] rather than raising, so callers can probe a path that may not exist yet.

micm_nlp.path.models_dir() → pathlib.Path

artefacts/models — saved checkpoints and PEFT adapters.

micm_nlp.path.output_dir(group: str | None, name: str) → pathlib.Path

The directory one run writes into: config snapshot, info.json, metrics, predictions, links, logs.

Parameters:

group – the group’s name, or None for a run started outside any group config – which lands under UNIT_RUNS instead.

micm_nlp.path.runs_dir() → pathlib.Path

artefacts/runs – one directory per run, under units/ or groups/{group}/. A run is neither an eval nor a training; it is the unit the trainer executes.

micm_nlp.path.set_root(workspace: str | pathlib.Path)

Set the workspace root. Call once at startup.

Raises:

ValueError – if no root was given. micm_nlp.init() passes its root_path straight through, and that is None when neither the call nor PROJECT_ROOT_PATH supplied one – which used to surface here as a TypeError from Path(None), naming neither the setting nor the fix.

micm_nlp.path.tokenizers_dir() → pathlib.Path

artefacts/tokenizers — tokenizers trained by this package.

micm_nlp.path.wandb_dir() → pathlib.Path

Parent directory for wandb’s own wandb/ folder.

Returns artefacts/ itself, not a subdirectory: wandb appends wandb/ to whatever it is given, so the run tree lands at artefacts/wandb/.

micm_nlp.path.workspace() → pathlib.Path

Return the workspace root.

Raises:

RuntimeError – if set_root() has not been called. Every accessor below goes through here, so an unset root fails loudly at the first path request rather than silently writing into the current directory.

micm_nlp.path.EXAMPLE_CONFIG_PACKAGE = 'micm_nlp.configs'

Where the example configs ship. Inside the package rather than downloaded, so the copy you get always matches the version you installed.

micm_nlp.path.GROUP_RUNS = 'groups'

runs/groups/{group}/{name}. One directory per group keeps an experiment whole – which is why no segment above it varies with the run. An earlier layout led with the model architecture, and split any group that varied the backbone across two trees.

Type:

Where a group’s runs land

micm_nlp.path.PACKAGE_DIR
micm_nlp.path.UNIT_RUNS = 'units'

runs/units/{name}.

Type:

Where a run started outside any group config lands