run_job

Contents

run_job#

rapidtools.jobs.run_job(job: Job | Mapping[str, Any] | str | Path, secrets: Secrets | Mapping[str, str] | str | Path | None = None, result_path: str | Path | None = None, progress: Callable[[str], None] | None = None, workflow: Any = None) → JobResult[source]#

Run a job file (or an in-memory job) and return its result.

This is the one-call form of JobRunner.

Parameters:
  • job (Job | Mapping[str, Any] | str | Path) – The job, a decoded job document, or the path of a job file.

  • secrets (Secrets | Mapping[str, str] | str | Path | None) – Secret values, or the path of a secrets file.

  • result_path (str | Path | None) – Where to write the result file. Defaults to <job file stem>.result.json next to the job file.

  • progress (Callable[[str], None] | None) – Receives progress messages.

  • workflow (Any) – A workflow engine to reuse. Defaults to a new one.

Returns:

JobResult – The outcome; result.ok tells whether it succeeded.

Raises:

JobError – If the job cannot be read at all.

Example

>>> from rapidtools.jobs import run_job
>>> result = run_job('jobs/detect.json', progress=print)
>>> result.status
'done'