Batch execution and runtime#

Utilities for looping over many studies on disk and exporting consistent manifests.

  • discover_study_dirs(root, selected=None) returns study folder paths (optionally filtered by name) with helpful error messages when nothing is found.

  • run_batch_studies(studies_root, study_loader, output_root, ...) iterates through discovered study folders, converts each to a Study via study_loader, runs analysis (default: study planner + executor), then calls save_study_results.

mrax.core.batch.discover_study_dirs(studies_root: str | Path, selected: Sequence[str] | None = None) → list[Path]#

Return study directories to process, optionally filtering by name.

mrax.core.batch.run_batch_studies(studies_root: str | Path, study_loader: Callable[[Path], Study | tuple[Study, dict[str, Any] | None]], output_root: str | Path, selected: Sequence[str] | None = None, analysis_fn: Callable[[...], list[dict[str, Any]]] | None = None, analysis_kwargs: dict[str, Any] | None = None, save_kwargs: dict[str, Any] | None = None, device: str | Device = 'cpu') → list[dict[str, Any]]#

Load studies from a folder, run analysis/fitting, and persist results.

The batch runner processes studies as independent jobs. Provide a study_loader that converts a study folder into a Study (plus optional metadata), and an optional analysis_fn to override the default Study planner/executor flow. Results are saved under output_root/<study_name> using save_study_results().

Returns a list of dictionaries summarizing each run with study_name, manifest_path, results, metadata, and study_dir keys.

Runtime helpers#

mrax.core.runtime.release_memory(*, gc_collect: bool = True, clear_jax_cache: bool = True) → None#

Release Python/JAX caches to reduce peak memory in long workflows.