Skip to content

Job

View source on GitHub

See Jobs and executors for command-line and Python examples.

JobRequest

Bases: BaseModel

Typed parameters for submitting a project job.

command class-attribute instance-attribute

command: list[str] = Field(
    min_length=1,
    description="Command as an argv list; each item is one literal argument.",
    examples=[
        "uv",
        "run",
        "my_script.py",
        "--option",
        "value",
    ],
)

executor class-attribute instance-attribute

executor: Literal[
    "local", "slurm", "local-detached", "renku"
] = Field(
    default="local-detached",
    description="Registered PSI/J executor name.",
)

record_id class-attribute instance-attribute

record_id: str | None = Field(
    default=None,
    description="Record ID to attribute this job to; omit for no attribution.",
)

executor_url class-attribute instance-attribute

executor_url: str | None = Field(
    default=None,
    description="Optional URL for the selected executor.",
)

custom_attributes class-attribute instance-attribute

custom_attributes: dict[str, str] | None = Field(
    default=None,
    description="Optional executor-specific string attributes.",
)

directory class-attribute instance-attribute

directory: str | None = Field(
    default=None,
    description="Optional working directory for the command.",
)

launcher class-attribute instance-attribute

launcher: str | None = Field(
    default=None,
    description="Optional registered PSI/J launcher name.",
)

Submission

Bases: BaseModel

Validated submission metadata persisted independently of execution.

id instance-attribute

id: str

record_id instance-attribute

record_id: str | None

submitted_at instance-attribute

submitted_at: AwareDatetime

observed_at instance-attribute

observed_at: AwareDatetime

executor class-attribute instance-attribute

executor: str = Field(min_length=1)

executor_url instance-attribute

executor_url: str | None

executor_work_directory class-attribute instance-attribute

executor_work_directory: str = Field(min_length=1)

native_id class-attribute instance-attribute

native_id: str = Field(min_length=1)

spec instance-attribute

spec: dict[str, Any]

status instance-attribute

status: Status

from_psi_job classmethod

from_psi_job(job: Job) -> Submission

Copy accepted job metadata without executing or writing anything.

View source on GitHub

get_psi_job

get_psi_job() -> psij.Job

Attach a native job without waiting, syncing, or saving metadata.

View source on GitHub

sync

sync(job: Job | None = None) -> None

Copy native status, allowing a fresh Slurm attachment time to poll.

View source on GitHub

save

save(project: Project) -> None

Atomically save submission metadata.

View source on GitHub

logs

logs(project: Project) -> dict[str, str | None]

Read available stdout and stderr files without observing the job.

View source on GitHub

cancel

cancel(project: Project) -> None

Cancel the native job and persist its resulting status.

View source on GitHub

load classmethod

load(project: Project, job_id: str) -> Submission

Read validated history without contacting an executor.

View source on GitHub

from_prefix classmethod

from_prefix(project: Project, prefix: str) -> Submission

Load the unique submission matching a UUID or nonempty prefix.

View source on GitHub

list classmethod

list(
    project: Project, *, record_id: str | None = None
) -> builtins.list[Submission]

Read history newest first, warning and continuing past corrupt entries.

View source on GitHub

Functions

get_executor

get_executor(
    name: str,
    *,
    work_directory: Path,
    url: str | None = None,
) -> psij.JobExecutor

Create an executor with an explicit auxiliary storage directory.

View source on GitHub

prepare_job

prepare_job(
    command: Sequence[str],
    *,
    project: Project,
    record_id: str | None = None,
    env: Mapping[str, str] | None = None,
    attributes: JobAttributes | None = None,
    resources: ResourceSpec | None = None,
    directory: Path | None = None,
    launcher: str | None = None,
) -> psij.Job

Construct a native PSI/J job with explicit research attribution.

Does not submit or write project history. Paths and resource requests describe the execution environment.

View source on GitHub

run_local

run_local(job: Job, *, project: Project) -> psij.JobStatus

Submit locally, stream output, and return the native final status.

Output uses temporary files unless the caller supplied output paths. Records the submission and its final native status in the project.

View source on GitHub

observe_submission

observe_submission(
    entry: Submission, project: Project
) -> dict[str, Any]

Return current submission data, saving observations of nonfinal jobs.

Observation failures return UNKNOWN and an error without changing history. Callers own warning reporting; storage failures propagate.

View source on GitHub