Project
The Project class represents a project in WhatsNext and provides methods for managing jobs.
Usage
from whatsnext.api.client import Server
server = Server("http://localhost:8000")
project = server.get_project("my-project")
# Queue jobs
project.append(name="job-1", parameters={"key": "value"})
# Get next job from queue
job = project.pop()
# List all jobs
jobs = project.jobs
API Reference
Project
Represents a project that contains tasks and jobs.
A Project is a container for organizing related work. It holds tasks (templates) and jobs (instances of tasks to execute).
clear_queue
Clear all pending jobs from the queue.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Number of jobs deleted. |
extend_queue
extend_queue(jobs: List[Job]) -> List[int]
Add multiple jobs to the queue.
| PARAMETER | DESCRIPTION |
|---|---|
jobs
|
List of Job objects to add.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[int]
|
List of created job IDs. |
fetch_job
fetch_job(
available_cpu: int = 0, available_accelerators: int = 0
) -> Job
Fetch the next pending job from the queue.
| PARAMETER | DESCRIPTION |
|---|---|
available_cpu
|
Filter jobs by available CPU (0 = no filter).
TYPE:
|
available_accelerators
|
Filter jobs by available accelerators (0 = no filter).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Job
|
The next job to execute. |
| RAISES | DESCRIPTION |
|---|---|
EmptyQueueError
|
If no jobs are pending. |
pop_queue
Remove a job from the queue by index.
| PARAMETER | DESCRIPTION |
|---|---|
idx
|
Index of the job to remove (0-based, by creation order).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the job was removed, False otherwise. |
remove_job
Remove a specific job from the queue.
| PARAMETER | DESCRIPTION |
|---|---|
job_id
|
The ID of the job to remove.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the job was removed, False otherwise. |