nirs4all.workspace package

Submodules

Module contents

Workspace management for nirs4all.

Provides: - Library management for saving and loading pipeline templates and trained models. - Active workspace path management for run output storage.

class nirs4all.workspace.LibraryManager(library_dir: Path)[source]

Bases: object

Manage library of saved pipelines.

list_filtered() List[Dict][source]

List all filtered pipelines.

Returns:

List of metadata dictionaries

list_fullruns() List[Dict][source]

List all saved full runs.

Returns:

List of metadata dictionaries

list_pipelines() List[Dict][source]

List all full pipelines.

Returns:

List of metadata dictionaries

list_templates() List[Dict][source]

List all available templates.

Returns:

List of template dictionaries

load_template(name: str) Dict[source]

Load a template by name.

Parameters:

name – Template name

Returns:

Template dictionary

save_filtered(pipeline_dir: Path, name: str, description: str = '') Path[source]

Save filtered pipeline (config + metrics only).

Useful for tracking experiments and comparing configurations.

Parameters:
  • pipeline_dir – Source pipeline directory

  • name – Save name

  • description – Optional description

Returns:

Path to saved filtered pipeline

save_fullrun(run_dir: Path, name: str, description: str = '') Path[source]

Save entire run (all pipelines + binaries + data).

Useful for complete experiment archiving and cross-dataset comparison.

Parameters:
  • run_dir – Run directory to save

  • name – Save name

  • description – Optional description

Returns:

Path to saved run

save_pipeline_full(run_dir: Path, pipeline_dir: Path, name: str, description: str = '') Path[source]

Save full pipeline (all files + binaries).

Useful for deployment, retraining, and full reproducibility.

Parameters:
  • run_dir – Parent run directory (contains _binaries/)

  • pipeline_dir – Pipeline directory

  • name – Save name

  • description – Optional description

Returns:

Path to saved pipeline

save_template(pipeline_config: Dict, name: str, description: str = '') Path[source]

Save pipeline template (config only, no trained artifacts).

Parameters:
  • pipeline_config – Pipeline configuration dictionary

  • name – Template name

  • description – Optional description

Returns:

Path to saved template file

nirs4all.workspace.get_active_workspace() Path[source]

Get the active workspace path.

Resolution order: 1. Explicitly set via set_active_workspace() 2. NIRS4ALL_WORKSPACE environment variable 3. ./workspace in current working directory (default)

Returns:

Path to the active workspace directory.

nirs4all.workspace.reset_active_workspace() None[source]

Reset the active workspace to the default.

Clears the explicitly set workspace and removes the environment variable, causing get_active_workspace() to return the default ./workspace path.

nirs4all.workspace.set_active_workspace(path: str | Path) None[source]

Set the active workspace path.

This also sets the NIRS4ALL_WORKSPACE environment variable to ensure child processes and other modules use the same workspace.

Parameters:

path – Path to the workspace directory.