api.job
createJob(name, user, request, result)
Creates a new job with the given parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
The name of the job. |
required |
user |
str
|
The user associated with the job. |
required |
request |
str
|
The request for the job. |
required |
result |
str
|
The result of the job. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A dictionary representing the created job. |
deleteJob(jobId)
Deletes a job with the given jobId.
Parameters: - jobId (str): The ID of the job to be deleted.
Returns: None
findJob(jobId)
Finds a job with the given jobId.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobId |
int
|
The ID of the job to find. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
A tuple containing the job object and its state. The job object is an instance of the Job class. The state is a string indicating the current state of the job. |
getFinishedJobs()
Retrieves a collection of finished jobs.
Returns:
| Name | Type | Description |
|---|---|---|
list |
A list of finished jobs. |
getJob(jobId, state='pending')
Retrieves a job based on the provided jobId and state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobId |
int
|
The ID of the job to retrieve. |
required |
state |
str
|
The state of the job. Defaults to "pending". |
'pending'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The job document. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an invalid state is provided. |
getJobResults(jobId)
Retrieves the results of a finished job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobId |
str
|
The ID of the job to retrieve results for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
A dictionary containing the job results. |
getJobSchema()
Returns the schema for a job object.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The schema for a job object. |
getJobs()
Retrieves all jobs from the system.
Returns:
| Type | Description |
|---|---|
|
A list of all jobs, including pending, running, and finished jobs. |
getPendingJobs()
Retrieves a collection of pending jobs.
Returns:
| Name | Type | Description |
|---|---|---|
list |
A list of pending jobs. |
getRunningJobs()
Retrieves the collection of running jobs.
Returns:
| Type | Description |
|---|---|
|
The collection of running jobs. |
setJob(jobId, data, state='pending')
Sets the job with the given jobId to the specified state and updates its data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobId |
any
|
The unique identifier of the job. |
required |
data |
any
|
The updated data for the job. |
required |
state |
str
|
The state to set the job to. Defaults to "pending". |
'pending'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The updated job information. |
Examples:
>>> setJob(123, {"name": "Job 1", "status": "completed"}, "completed")
{'jobId': 123, 'name': 'Job 1', 'status': 'completed'}
setJobFinished(jobId, data)
Sets the status of a job to 'finished' and returns the updated job information.
Parameters: - jobId (int): The ID of the job to update. - data (dict): The data to update the job with.
Returns: - dict: The updated job information.
setJobPending(jobId, data)
Sets the status of a job to 'pending'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobId |
int
|
The ID of the job. |
required |
data |
dict
|
Additional data for the job. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The updated job information. |
setJobRunning(jobId, data)
Sets the status of a job to 'running'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobId |
int
|
The ID of the job. |
required |
data |
dict
|
Additional data for the job. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing the updated job information. |
updateJobResult(jobId, data, inputJob=None)
Updates the result of a job with the given jobId. Also sets the job status to 'finished'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jobId |
str
|
The ID of the job to update. |
required |
data |
any
|
The result data to be assigned to the job. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Job Schema
The job schema is a JSON object that defines the structure of a job. It contains the following fields:
| Field | Type | Required | Unique | Default | Options |
|---|---|---|---|---|---|
| id | string | True | True | ||
| name | string | False | False | ||
| user | string | False | False | ||
| request | string | False | False | ||
| result | string | False | False | ||
| status | string | False | False | idle | idle, pending, running, finished, error |
| messages | string | False | False |
JSON Schema
{
"id":{"type":"string", "required":True, "unique":True, "default": "","options":[]},
"name":{"type":"string", "required":False, "unique":False, "default": "","options":[]},
"user":{"type":"string", "required":False, "unique":False, "default": "","options":[]},
"request":{"type":"string", "required":False, "unique":False, "default": "","options":[]},
"result":{"type":"string", "required":False, "unique":False, "default": "","options":[]},
"status":{"type":"string", "required":False, "unique":False, "default": "idle", "options":["idle","pending", "running", "finished", "error"]},
"messages":{"type":"string", "required":False, "unique":False, "default": "","options":[]},
}