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[JobSummary]
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 whose schedule is in this state:active(its schedule runs it) orpaused(it still runs when started by hand). Not whether a job is running: that is each job'slast_runstatus, and a paused job can be running.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[JobSummary]: 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, retries: int | None = None, retry_delay_seconds: int | 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.
A size is the whole workload: Strongly's helper services beside it
(sign-in proxy, outbound proxy, data volume mounts, model cache upload,
metrics) are taken out of it, never added on top (set 4 GB and the workload
uses 4 GB in total). A size too small to hold them is refused naming them.
A CPU, memory, GPU count or disk above the largest allowed machine's room
for one workload raises APIError with status_code 400 naming the
resource and both figures, and nothing is created or changed. Check
client.compute.list_pools() allowed_sizes (max_cpu,
max_memory_gib, max_disk_gib, max_gpus) before a large size.
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):Trueruns each run on spot capacity (cheaper; a run can be interrupted when the capacity is reclaimed).spot_fallback(bool | None, optional): Withuse_spot:True(the API's default) falls back to on-demand capacity when no spot is available;Falsewaits for spot.retries(int | None, optional): How many times a failed run is tried again, 0 to 10 (the API's default is 0). Each try is its own execution (attemptofmax_attempts, linked to the first byfirst_execution_id) with its own log and exit code; a try that succeeds, a cancel or a refusal (governance, budget, size) ends the tries.retry_delay_seconds(int | None, optional): Seconds between a failed try and the next, 0 to 86400 (the API's default is 60).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'sSTRONGLY_SERVICESholds ([]for none).ml_models, feature_stores, agents(Sequence[str]): The ids of the deployed ML models, feature stores and agents whose connections each run'sSTRONGLY_SERVICESholds ([]for none).description(str | None, optional): What the job does.environment_id(str | None, optional): A saved environment (its image and size). Without one,resourcesgives 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:cpuandmemory(required then), anddisk,gpu,gpu_type, e.g.{"cpu": "1", "memory": "4GB"}. No size is assumed.gpu_type(own or the saved environment's): One of the typeslist_gpu_optionslists (the admin Compute selection); any other is refused with a 400ValidationError.env_vars(Mapping[str, str] | None, optional): Environment variables set in each run.schedule(Mapping[str, Any] | None, optional):{"type": "manual"}(on demand only),{"type": "cron", "cron": "0 2 * * *", "timeZone": "America/New_York"}(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, retries: int | None = None, retry_delay_seconds: int | 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, ml_models: Sequence[str] | None = None, feature_stores: Sequence[str] | None = None, agents: Sequence[str] | None = None, shared_volume_ids: Sequence[str] | None = None) -> Job
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.
A size is the whole workload: Strongly's helper services beside it
(sign-in proxy, outbound proxy, data volume mounts, model cache upload,
metrics) are taken out of it, never added on top (set 4 GB and the workload
uses 4 GB in total). A size too small to hold them is refused naming them.
A CPU, memory, GPU count or disk above the largest allowed machine's room
for one workload raises APIError with status_code 400 naming the
resource and both figures, and nothing is created or changed. Check
client.compute.list_pools() allowed_sizes (max_cpu,
max_memory_gib, max_disk_gib, max_gpus) before a large size.
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, orcustomto useresources.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 (seecreate).workspace_volume_size(str | None, optional): Each run's own working storage, e.g."40GB".use_spot(bool | None, optional):Trueruns each run on spot capacity (cheaper; a run can be interrupted when the capacity is reclaimed).spot_fallback(bool | None, optional): Withuse_spot:True(the API's default) falls back to on-demand capacity when no spot is available;Falsewaits for spot.retries(int | None, optional): How many times a failed run is tried again, 0 to 10, from the next run (a run already going keeps the tries it started with).retry_delay_seconds(int | None, optional): Seconds between a failed try and the next, 0 to 86400, from the next run.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 (seecreate).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.ml_models, feature_stores, agents(Sequence[str] | None, optional): Deployed ML model, feature store and agent ids, each replacing the job's.
Returns
Job: The job as saved.
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), asretrieve_executionshows it; follow itsstatusthere.
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, which is then not tried again.
Answers at once. A running run is cancelling while its command
stops (every process of it) and every file it wrote is saved; poll
retrieve_execution until it is cancelled, or failed with
error naming each file that could not be saved. A try waiting for
its time (the job's retries) is cancelled at once and never starts.
Cancelling a run that is already cancelling (a command that ignores
the stop) kills the command's processes; its files are still saved
before the run ends, the same way.
Parameters
job_id(str): The job's id.execution_id(str): The run's id.
Returns
JobExecution: The run:cancelling(orcancelledfor a waiting try), or as it ended when it had already finished.
download_execution_log
download_execution_log(job_id: str, execution_id: str, dst_path: str | os.PathLike[str] | None = None) -> str
Download a run's whole log and return where it was saved.
It comes straight from storage through a signed link
(execution_log_download_link), written to disk as it arrives.
dst_path is a file, or a folder to save it in (default: its name, in
the current folder).
Parameters
job_id(str): The job's id.execution_id(str): The run's id.dst_path(str | os.PathLike[str] | None, optional): Where to save it: a file, or a folder (default: the current folder).
Returns
str: The path it was saved to.
execution_log_download_link
execution_log_download_link(job_id: str, execution_id: str) -> DownloadLink
Return a signed link (5 minutes) to a run's whole log, <job>-<run>.log.
For a running run, the log written so far.
Parameters
job_id(str): The job's id.execution_id(str): The run's id.
execution_log_url
execution_log_url(job_id: str, execution_id: str) -> str
Return a URL that shows a run's whole log, valid for 5 minutes.
For a running run, the log written so far. download_execution_log
saves it as a file.
Parameters
job_id(str): The job's id.execution_id(str): The run's id.
Returns
str: The URL.
execution_pod
execution_pod(job_id: str, execution_id: str) -> WorkerStatus
Read what runs a job run right now (live).
Its phase, every container's ready flag, restart count and state, how
a container's last run ended (last_terminated.reason, such as
OOMKilled), and why it is not running yet (pending_reasons).
Once the run has ended, its worker as it was at its end.
Parameters
job_id(str): The job's id.execution_id(str): The run's id.
Returns
WorkerStatus: The run's worker.
Raises
NotFoundError: The run has no worker yet.
list_executions
list_executions(job_id: str, *, limit: int | None = None) -> SyncPaginator[JobExecutionSummary]
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[JobExecutionSummary]: 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 whole log.
logs holds every line of the run's log so far (a finished run's, or what a running
run has written); download_execution_log saves it as a file.
Parameters
job_id(str): The job's id.execution_id(str): The run's id.
Returns
JobExecution: The run.