Skip to content

Job

The Job class represents a queued job and provides methods for execution and status management.

Usage

from whatsnext.api.client import Server

server = Server("http://localhost:8000")
project = server.get_project("my-project")

# Get next job
job = project.pop()

if job:
    print(f"Processing: {job.name}")
    print(f"Parameters: {job.parameters}")
    print(f"Status: {job.status}")

    # Execute the job
    job.run()

Job Status

Jobs progress through the following states:

  • PENDING - Job created but not queued
  • QUEUED - Job in queue waiting to be processed
  • RUNNING - Job currently being executed
  • COMPLETED - Job finished successfully
  • FAILED - Job execution failed

API Reference

Job

Represents a job to be executed.

A Job is a data object containing execution parameters. The actual execution is handled by a Formatter, keeping job definitions runtime-agnostic.

run

run(resource: 'Resource') -> int

Execute the job using the resource's formatter.

PARAMETER DESCRIPTION
resource

Resource containing the client and formatter to use.

TYPE: 'Resource'

RETURNS DESCRIPTION
int

Exit code from the command execution.

set_depends_to

set_depends_to(depends: List['Job']) -> None

Update job dependencies on the server.

set_priority_to

set_priority_to(priority: int) -> None

Update job priority on the server.

set_status

set_status(status: str) -> None

Update job status on the server.