Skip to main content

Jobs

Project jobs: a command line run with bash in a project's code folder.

Access it as client.jobs on a Strongly client, or the same path on AsyncStrongly with await. All methods exist on both with identical signatures.

Quick start​

from strongly import Strongly

client = Strongly()

# List (auto-paginates as you iterate) # filters: project_id, status, search, sort
for job in client.jobs.list():
print(job.id)

Methods​

Core​

list​

list(*, project_id: str | None = None, status: str | None = None, search: str | None = None, sort: str | None = None, limit: int | None = None) -> SyncPaginator[Job]

List the jobs you can see, across your projects or of one project.

Parameters

  • project_id (str | None, optional): Only this project's jobs.
  • status (str | None, optional): Only jobs with this status: active or paused.
  • search (str | None, optional): Jobs whose name or description contains this text (any case).
  • sort (str | None, optional): The field to sort by, - first for descending (the API's default is -createdAt).
  • limit (int | None, optional): The most jobs to return; every matching job when not given.

Returns

  • SyncPaginator[Job]: The jobs, fetched a page at a time as they are iterated.

create​

create(*, project_id: str, name: str, command: str, workspace_volume_size: str, use_spot: bool | None = None, spot_fallback: bool | None = None, addons: Sequence[str], data_sources: Sequence[str], ai_models: Sequence[str], workflows: Sequence[str], ml_models: Sequence[str], feature_stores: Sequence[str], agents: Sequence[str], description: str | None = None, environment_id: str | None = None, environment_version: int | None = None, resources: Mapping[str, Any] | None = None, env_vars: Mapping[str, str] | None = None, schedule: Mapping[str, Any] | None = None, shared_volume_ids: Sequence[str] | None = None) -> Job

Create a job in a project.

Parameters

  • project_id (str): The project the job belongs to: each run mounts its volume and runs the command in its code folder.
  • name (str): The job's name.
  • command (str): The command line each run runs with bash, with whatever the environment's image has installed, e.g. "python3 train.py --epochs 3".
  • workspace_volume_size (str): Each run's own working storage, in whole GB, e.g. "20GB".
  • use_spot (bool | None, optional): True runs each run on spot capacity (cheaper; a run can be interrupted when the capacity is reclaimed).
  • spot_fallback (bool | None, optional): With use_spot: True (the API's default) falls back to on-demand capacity when no spot is available; False waits for spot.
  • shared_volume_ids (Sequence[str] | None, optional): The shared volumes each run mounts at /volumes/shared/<name>; none unless listed (the project's volume always mounts). A volume the job's creator may not mount is refused, by name.
  • addons, data_sources, ai_models, workflows (Sequence[str]): The ids of the add-ons, data sources, AI models and workflows whose connections each run's STRONGLY_SERVICES holds ([] for none).
  • ml_models, feature_stores, agents (Sequence[str]): The ids of the deployed ML models, feature stores and agents whose connections each run's STRONGLY_SERVICES holds ([] for none).
  • description (str | None, optional): What the job does.
  • environment_id (str | None, optional): A saved environment (its image and size). Without one, resources gives the size and the platform's runtime image is used.
  • environment_version (int | None, optional): A version of that environment to pin; its latest when not given.
  • resources (Mapping[str, Any] | None, optional): The size of each run without a saved environment: cpu and memory (required then), and disk, gpu, gpu_type, e.g. {"cpu": "1", "memory": "4GB"}. No size is assumed.
  • env_vars (Mapping[str, str] | None, optional): Environment variables set in each run.
  • schedule (Mapping[str, Any] | None, optional): {"type": "manual"} (on demand only), &#123;"type": "cron", "cron": "0 2 * * *", "timeZone": "America/New_York"&#125; (times local to the IANA zone), or {"type": "once", "runAt": "<ISO date>"}.

Returns

  • Job: The new job.

Raises

  • ValidationError: A required field is missing, the command is empty, or no size was given without a saved environment.

retrieve​

retrieve(job_id: str) -> Job

Return a job.

Parameters

  • job_id (str): The job's id.

Returns

  • Job: The job, with its latest run.

update​

update(job_id: str, *, name: str | None = None, description: str | None = None, command: str | None = None, environment_id: str | None = None, environment_version: int | None = None, resources: Mapping[str, Any] | None = None, workspace_volume_size: str | None = None, use_spot: bool | None = None, spot_fallback: bool | None = None, env_vars: Mapping[str, str] | None = None, schedule: Mapping[str, Any] | None = None, addons: Sequence[str] | None = None, data_sources: Sequence[str] | None = None, ai_models: Sequence[str] | None = None, workflows: Sequence[str] | None = None, shared_volume_ids: Sequence[str] | None = None) -> None

Change a job; only the fields given change.

Pause and resume it with pause and resume. A new schedule is used from its next run; switching environment without a version runs the new environment's latest.

Parameters

  • job_id (str): The job's id.
  • name (str | None, optional): The job's name.
  • description (str | None, optional): What the job does.
  • command (str | None, optional): The command line each run runs.
  • environment_id (str | None, optional): A saved environment, or custom to use resources.
  • environment_version (int | None, optional): A version of that environment to pin.
  • resources (Mapping[str, Any] | None, optional): The size of each run without a saved environment (see create).
  • workspace_volume_size (str | None, optional): Each run's own working storage, e.g. "40GB".
  • use_spot (bool | None, optional): True runs each run on spot capacity (cheaper; a run can be interrupted when the capacity is reclaimed).
  • spot_fallback (bool | None, optional): With use_spot: True (the API's default) falls back to on-demand capacity when no spot is available; False waits for spot.
  • shared_volume_ids (Sequence[str] | None, optional): The shared volumes its runs mount from the next run, replacing the list ([] for none). A volume the job's creator may not mount is refused, by name.
  • env_vars (Mapping[str, str] | None, optional): Environment variables set in each run, replacing the job's.
  • schedule (Mapping[str, Any] | None, optional): When the job runs by itself (see create).
  • addons (Sequence[str] | None, optional): Add-on ids, replacing the job's.
  • data_sources (Sequence[str] | None, optional): Data source ids, replacing the job's.
  • ai_models (Sequence[str] | None, optional): AI model ids, replacing the job's.
  • workflows (Sequence[str] | None, optional): Workflow ids, replacing the job's.

delete​

delete(job_id: str) -> None

Delete a job; its live runs are cancelled.

Parameters

  • job_id (str): The job's id.

Lifecycle & actions​

pause​

pause(job_id: str) -> Job

Pause a job: its scheduled runs stop until it is resumed; returns the job.

Parameters

  • job_id (str): The job's id.

resume​

resume(job_id: str) -> Job

Resume a paused job; returns the job.

Parameters

  • job_id (str): The job's id.

run​

run(job_id: str) -> JobExecution

Start a run of a job now, as you.

Parameters

  • job_id (str): The job's id.

Returns

  • JobExecution: The run it started (202), as retrieve_execution shows it; follow its status there.

Raises

  • ConflictError: A run of the job is still going.
  • PermissionDeniedError: Governance refused the run (it is recorded in the run history with the reason).

Other​

cancel_execution​

cancel_execution(job_id: str, execution_id: str) -> JobExecution

Cancel a run: it is stopped and recorded cancelled.

Parameters

  • job_id (str): The job's id.
  • execution_id (str): The run's id.

Returns

  • JobExecution: The run, cancelled, or as it ended when it had already finished.

execution_log_url​

execution_log_url(job_id: str, execution_id: str, *, download: bool | None = None) -> str

Return a URL to a run's whole log, valid for 5 minutes.

For a running run, the log written so far.

Parameters

  • job_id (str): The job's id.
  • execution_id (str): The run's id.
  • download (bool | None, optional): True: the URL downloads the log as a file.

Returns

  • str: The URL.

list_executions​

list_executions(job_id: str, *, limit: int | None = None) -> SyncPaginator[JobExecution]

List a job's runs, newest first.

Parameters

  • job_id (str): The job's id.
  • limit (int | None, optional): The most runs to return; every run when not given.

Returns

  • SyncPaginator[JobExecution]: The runs, fetched a page at a time as they are iterated.

retrieve_execution​

retrieve_execution(job_id: str, execution_id: str) -> JobExecution

Return a run: its status, trigger, user, command, exit code, error and log tail.

Parameters

  • job_id (str): The job's id.
  • execution_id (str): The run's id.

Returns

  • JobExecution: The run.