m3resp.run_spec#

m3resp.run_spec(path, *, session=None, eit_adapter=None, emg_adapter=None, event_sink=None, cancellation_token=None)[source]#

Run a workflow file, write its manifest and apply its export settings.

Resolves a timestamped output directory once for the run and supplies it, output settings and experiment metadata to the steps. An inferred output mode in an unversioned spec emits a FutureWarning.

Parameters:
  • path (str | Path) – YAML or JSON workflow file. Relative paths within the file are resolved against its parent directory.

  • session (M3Session | None) – Session to process; None creates a new session.

  • eit_adapter (Any) – EIT adapter used when creating a new session.

  • emg_adapter (Any) – EMG adapter used when creating a new session.

  • event_sink (Callable[[dict[str, Any]], None] | None) – Optional synchronous progress-event receiver.

  • cancellation_token (CancellationToken | None) – Optional flag checked between steps.

Returns:

The executed workflow’s results, with its resolved

output directory and manifest path when configured. Automatic mode exports the successful session; explicit mode uses the declared export steps. Requested figures are saved for successful runs in either mode. With outputs.dir and a mode other than none, writes run_manifest.json before execution and replaces it with the terminal run state before applying automatic exports.

Return type:

WorkflowResult

Raises:
  • WorkflowSpecError – If the spec or workflow bindings are invalid.

  • UnknownStepError – If the first structural error names an unknown step.

  • WorkflowExecutionError – If a step function fails. The failure is written to the configured manifest before this error is re-raised.

  • OSError – If the spec cannot be read or an output cannot be written.