Tasks
Some endpoints do not return a direct response. Instead they return a
task_id
which will contain the results once ready. In most cases you will need to get the task until the status is not pending
. The status will then either be:success
: in which case you can read thedata
field to access the expected response.error
: in which case theerror
field will contain an error message and thedata
field will be null.
Attribute | Type | Description |
id | string | The task ID |
status | string | The task status, either "pending" , "success" , or "error" |
error | string | Defined in case of error, it is the error message |
date_created | string | The creation data timestamp |
date_updated | string | The timestamp where status switched from "pending" to another status |
data | object | The response JSON of the endpoint that generated the task |
JSON
{
"id": "269999729",
"status": "success",
"error": null,
"date_created": "2018-03-10T20:38:12.818792Z",
"date_updated": "2018-03-10T20:38:13.032942Z",
"data": {
"outputs": [
{
"labels": {
"discarded": [],
"predicted": [
{
"threshold": 0.025,
"label_id": 207,
"score": 0.952849746,
"label_name": "golden retriever"
}
]
}
}
]
},
"subtasks": null
}
This endpoint retrieves the state of a given task.
cURL
Python
TASK_ID=123
curl https://api.deepomatic.com/v0.7/tasks/${TASK_ID} \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}"
client.Task.retrieve({TASK_ID})
Parameter | Type | Default | Description |
task_id | string | | The task ID |
cURL
Python
curl https://api.deepomatic.com/v0.7/tasks/269999729 \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}"
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))
client.Task.retrieve(269999729)
JSON
{
"id": "269999729",
"status": "success",
"error": null,
"date_created": "2018-03-10T20:38:12.818792Z",
"date_updated": "2018-03-10T20:38:13.032942Z",
"data": {
"outputs": [
{
"labels": {
"discarded": [],
"predicted": [
{
"threshold": 0.025,
"label_id": 207,
"score": 0.952849746,
"label_name": "golden retriever"
}
]
}
}
]
},
"subtasks": null
}
Retrieve several tasks status given their IDs.
cURL
Python
GET https://api.deepomatic.com/v0.7/tasks
tasks = client.Task.list(task_ids=[...])
Parameter | Type | Default | Description |
task_ids | array(string) | | The task IDs as a JSON array of strings |
cURL
Python
curl https://api.deepomatic.com/v0.7/tasks?task_ids=269999729&task_ids=269999730 \
-H "X-API-KEY: ${DEEPOMATIC_API_KEY}"
import os
from deepomatic.api.client import Client
client = Client(api_key=os.getenv('DEEPOMATIC_API_KEY'))
tasks = client.Task.list(task_ids=[269999729, 269999730])
Attribute | Type | Description |
count | int | The total number of results. |
next | string | The URL to the next page. |
previous | string | The URL to the previous page. |
results |
JSON
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": "269999729",
"status": "success",
"error": null,
"date_created": "2018-03-10T20:38:12.818792Z",
"date_updated": "2018-03-10T20:38:13.032942Z",
"data": {
"outputs": [
{
"labels": {
"predicted": [
{
"threshold": 0.025,
"label_id": 207,
"score": 0.952849746,
"label_name": "golden retriever"
}
],
"discarded": []
}
}
]
},
"subtasks": null
},
{
"id": "269999730",
"status": "success",
"error": null,
"date_created": "2018-03-10T20:39:47.346716Z",
"date_updated": "2018-03-10T20:39:47.553246Z",
"data": {
"outputs": [
{
"labels": {
"predicted": [
{
"threshold": 0.025,
"label_id": 207,
"score": 0.952849746,
"label_name": "golden retriever"
}
],
"discarded": []
}
}
]
},
"subtasks": null
}
]
}
Last modified 2yr ago