nvflare.recipe.run module

class Run(exec_env: ExecEnv, job_id: str)[source]

Bases: object

Represents a running or completed job execution.

Provides methods to get job status, results, and abort the job. Caches status and result after the execution environment is stopped.

This class is thread-safe. All state-changing operations are protected by a lock.

Initialize a Run instance.

Parameters:
  • exec_env – The execution environment managing this job.

  • job_id – The unique identifier for the job.

Raises:

ValueError – If exec_env is None or job_id is empty.

abort() None[source]

Abort the running job.

This is a no-op if the execution environment has already been stopped (e.g., after get_result() was called). Errors are logged but not raised.

get_job_id() str[source]

Get the job ID.

Returns:

The job ID.

Return type:

str

get_result(timeout: float = 0.0, clean_up: bool = True) str | None[source]

Get the result workspace of the run.

Waits for job to complete, caches status, then stops execution environment.

Parameters:
  • timeout (float, optional) – Timeout for job completion. Defaults to 0.0 (no timeout).

  • clean_up (bool, optional) – Whether to remove the execution-environment workspace (e.g. the POC workspace) when stopping. Defaults to True, preserving the existing “each run is independent” behavior. Pass clean_up=False to keep the workspace on disk after the run so server/client log files (including the per-service poc_console.log introduced in #4500) remain available for debugging or test assertions.

Returns:

Result workspace path, or None if job not finished or on error. The path may be removed by the time this method returns when clean_up=True.

Return type:

Optional[str]

get_status() str | None[source]

Get the status of the run.

Returns:

The status of the run, or None if not available or on error.

Return type:

Optional[str]