Once a job has been created, it can be managed through the AI Data GraphQL API, or via the AI Processing REST API. Jobs can be canceled before they have started running, and any job that has not completed yet can be retried.
Before you begin
- To manage jobs using either the AI Data GraphQL API or the AI Processing REST API, you must first Get a token.
- These instructions assume that you have the job's
ID.
- If the job is created using the AI Processing REST API, the
InternalJobId is returned with the CreateJobResponse. - If the job is created using the AI Data GraphQL API, be sure to request the job
ID in the response. An example of this is shown in Run a job using GraphQL.
Canceling jobs
A job can be canceled if both the job and all of its associated tasks have one of the following statuses:
An exception is that if the job's status is running, but all of the tasks are still either pending or queued, the job can still be canceled.
Check a job's status
To see an example of checking a job's status in GraphQL, see Run a job using GraphQL.
To check a job's status using the AI Processing REST API, send a GET request to /proc/job/<_YOUR_JOB_ID>/status. An example using curl is:
curl --request GET \
--url http://localhost:9000/edge/v1/proc/job/<YOUR_JOB_ID>/status \
--header 'Authorization: Bearer <YOUR_TOKEN>' \
--header 'Content-Type: application/json' \
Where
<YOUR_JOB_ID> is the InternalJobID <YOUR_TOKEN> is your authentication token
A successfully canceled job will have a status of aborted.
Cancel a job using the AI Data API
Both scheduled and ad hoc jobs can be canceled via the AI Data API.
Cancel an ad hoc job
Use the cancelJob mutation and pass the job's id.
mutation cancelJob {
cancelJob(id: "<YOUR_JOB_ID>") {
id
message
}
}
Where
<YOUR_JOB_ID> is the InternalJobID
A sample response is:
{
"data": {
"cancelJob": {
"id": "23041407_RORjiJw7te",
"message": "Job cancelled"
}
}
}
Cancel a scheduled job
To cancel a scheduled job, use the updateScheduledJob mutation and set isActive tofalse.
mutation updateScheduledJob {
updateScheduledJob(
input: {
id: <YOUR_JOB_ID>
isActive: false
isPublic: false
runMode: Once
}
) {
id
name
}
}
Where
<YOUR_JOB_ID> is the ID of the scheduled job
A sample response is:
{
"data": {
"updateScheduledJob": {
"id": "123456",
"name": "qv3TestEverye5Minute"
}
}
}
Cancel a job using the AI Processing REST API
Both scheduled and ad hoc jobs can be canceled using the AI Processing API, and multiple jobs can be canceled for a single organization for a specified time range. Use the AI Processing API to:
Cancel an ad hoc job via AI Processing
Send a POST request to /proc/jobs/cancel and pass the job's ID.
curl --request POST \
--url http://localhost:9000/edge/v1/proc/jobs/cancel \
--header 'Authorization: Bearer <YOUR_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"jobID": "<YOUR_JOB_ID>"
}'
Where
<YOUR_TOKEN> is your authentication token<YOUR_JOB_ID> is the InternalJobID
Cancel a scheduled job via AI Processing
Send a POST request to /proc/jobs/cancel and provide the ID of the scheduled job.
curl --request POST \
--url http://localhost:9000/edge/v1/proc/jobs/cancel \
--header 'Authorization: Bearer <YOUR_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"scheduledJobID": "<YOUR_JOB_ID>"
}'
Where
<YOUR_TOKEN> is your authentication token<YOUR_JOB_ID> is the ID of the scheduled job
Cancel multiple jobs for an organization
To cancel multiple jobs for a single organization, send a POST request to /proc/jobs/cancel and specify an organizationIDand a time range.
curl --request POST \
--url http://localhost:9000/edge/v1/proc/jobs/cancel \
--header 'Authorization: Bearer <YOUR_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"organizationID": "<ORG_ID>",
"createdBeforeDateTime": "2022-09-26T16:21:22+00:00",
"createdAfterDateTime": "2022-08-26T16:21:22+00:00"
}'
Where
<YOUR_TOKEN> is your authentication token<ORG_ID> is the ID of the organization
Retry a job
A job can be retried using the AI Data API if its status is not complete. Retrying a job duplicates the existing job, uses the same engines and payloads, and submits it as a new job. AI Processing receives the newly created job, so there is no endpoint for retry in the AI Processing API.
Retry a job using the AI Data API
Use the retryJob mutation and pass the job's id.
mutation retryJob {
retryJob(id: "<YOUR_JOB_ID>") {
id
}
}
Where
<YOUR_JOB_ID> is the InternalJobID
The returned id is the ID of the newly created job.