API Client represents a low level interface for datasets API. All API operation can performed using this.
abeja.datasets.
APIClient
(credential: typing.Union[dict, NoneType] = None, timeout: typing.Union[int, NoneType] = None, max_retry_count: typing.Union[int, NoneType] = None)¶A Low-Level client for Dataset API
from abeja.datasets import APIClient
api_client = APIClient()
bulk_update_dataset_item
(organization_id: str, dataset_id: str, bulk_attributes: typing.Union[dict, NoneType] = None) → dict¶update a item in a dataset
API reference: PUT /organizations/<organization_id>/datasets/<dataset_id>/items
Request syntax:
bulk_attributes = [ { "dataset_item_id": 1111111111111, "attributes": { "classification": [ { "category_id": 1, "label_id": 1 } ], "custom_format": { "anything": "something" }, "detection": [ { "category_id": 1, "label_id": 2, "rect": { "xmin": 22, "ymin": 145, "xmax": 140, "ymax": 220 } } ] } } ] api_client.bulk_update_dataset_item(organization_id='1102940376065', dataset_id='1410805969256', bulk_attributes=bulk_attributes )
[
{
"organization_id": "1200000000000",
"dataset_id": "1440000000000",
"dataset_item_id": 101554,
"source_data": [
{
"data_type": "image/jpeg",
"data_uri": "datalake://1230000000000/20180520T133855-10051aa4-d7aa-43a1-8d5e-4d59dae5bb83"
}
],
"attributes": {
"classification": {
"category_id": 1,
"label_id": 1
},
"detection": [
{
"category_id": 1,
"label_id": 2,
"rect": {
"xmin": 22,
"ymin": 145,
"xmax": 140,
"ymax": 220
}
}
]
},
"created_at": "2018-05-20T13:51:16.010344",
"updated_at": "2018-05-20T13:51:16.010344"
}
]
create_dataset
(organization_id: str, name: str, type: str, props: dict) → dict¶create a dataset
API reference: POST /organizations/<organization_id>/datasets/
organization_id = "1102940376065"
dataset_name = "test-dataset"
dataset_type = "classification"
props = {
"categories": [
{
"labels": [
{
"label_id": 1,
"label": "dog"
},
{
"label_id": 2,
"label": "cat"
},
{
"label_id": 3,
"label": "others"
}
],
"category_id": 1,
"name": "cats_dogs"
}
]
}
response = api_client.create_dataset(organization_id, dataset_name, dataset_type, props)
Response Syntax:
{
"created_at": "2018-04-10T07:49:30.514794",
"dataset_id": "1410805969256",
"name": "test-dataset",
"organization_id": "1102940376065",
"props": {
"categories": [
{
"labels": [
{
"label_id": 1,
"label": "dog"
},
{
"label_id": 2,
"label": "cat"
},
{
"label_id": 3,
"label": "others"
}
],
"category_id": 1,
"name": "cats_dogs"
}
]
},
"type": "classification",
"updated_at": "2018-04-10T07:49:30.514794"
}
create_dataset_item
(organization_id: str, dataset_id: str, source_data: dict, attributes: typing.Union[dict, NoneType] = None) → dict¶create a item in a dataset
API reference: POST /organizations/<organization_id>/datasets/<dataset_id>/items/
source_data = [
{
"data_type": "image/jpeg",
"data_uri": "datalake://1200123803688/20170815T044617-f20dde80-1e3b-4496-bc06-1b63b026b872",
"height": 500,
"width": 200
}
]
attributes = {
"classification": [
{
"category_id": 1,
"label_id": 1,
}
],
"custom": [
{
"anything": "something"
}
],
"detection": [
{
"category_id": 1,
"label_id": 2,
"rect": {
"xmin": 22,
"ymin": 145,
"xmax": 140,
"ymax": 220
}
},
]
}
response = api_client.create_dataset_item(
organization_id="1102940376065",
dataset_id="1410805969256",
source_data=source_data,
attributes=attributes
)
{
"attributes": {
"classification": [
{
"category_id": 1,
"label_id": 1
}
],
"custom": [
{
"anything": "something"
}
],
"detection": [
{
"category_id": 1,
"label_id": 2,
"rect": {
"xmin": 22,
"ymin": 145,
"xmax": 140,
"ymax": 220
}
},
]
},
"created_at": "2017-12-27T06:25:00.394026",
"dataset_id": "1410805969256",
"dataset_item_id": 0,
"source_data": [
{
"data_type": "image/jpeg",
"data_uri": "datalake://1200123803688/20170815T044617-f20dde80-1e3b-4496-bc06-1b63b026b872",
"height": 500,
"width": 200
}
],
"organization_id": "1102940376065",
"updated_at": "2017-12-27T06:25:00.394026"
}
delete_dataset
(organization_id: str, dataset_id: str) → dict¶delete a dataset
API reference: DELETE /organizations/<organization_id>/datasets/<dataset_id>
response = api_client.delete_dataset(organization_id='1102940376065', dataset_id='1410805969256')
{
"created_at": "2018-04-10T07:49:30.514794",
"dataset_id": "1410805969256",
"name": "test-dataset",
"organization_id": "1102940376065",
"props": {
"categories": [
{
"labels": [
{
"label_id": 1,
"label": "dog"
},
{
"label_id": 2,
"label": "cat"
},
{
"label_id": 3,
"label": "others"
}
],
"category_id": 1,
"name": "cats_dogs"
}
]
},
"type": "classification",
"updated_at": "2018-04-10T07:49:30.514794"
}
delete_dataset_item
(organization_id: str, dataset_id: str, dataset_item_id: str) → dict¶delete a item in a dataset
API reference: DELETE /organizations/<organization_id>/datasets/<dataset_id>/items/<dataset_item_id>
api_client.delete_dataset_item(organization_id='1102940376065',
dataset_id='1410805969256',
dataset_item_id=0
)
get_dataset
(organization_id: str, dataset_id: str) → dict¶get a dataset
API reference: GET /organizations/<organization_id>/datasets/<dataset_id>
response = api_client.get_dataset(organization_id='1102940376065', dataset_id='1410805969256')
{
"created_at": "2018-04-10T07:49:30.514794",
"dataset_id": "1410805969256",
"total_count": 3670,
"name": "test-dataset",
"organization_id": "1102940376065",
"props": {
"categories": [
{
"labels": [
{
"label_id": 1,
"label": "dog"
},
{
"label_id": 2,
"label": "cat"
},
{
"label_id": 3,
"label": "others"
}
],
"category_id": 1,
"name": "cats_dogs"
}
]
},
"type": "classification",
"updated_at": "2018-04-10T07:49:30.514794"
}
get_dataset_item
(organization_id: str, dataset_id: str, dataset_item_id: str) → dict¶get a item in a dataset
API reference: GET /organizations/<organization_id>/datasets/<dataset_id>/items/<dataset_item_id>
response = api_client.get_dataset_item(organization_id='1102940376065',
dataset_id='1410805969256',
dataset_item_id=0
)
{
"attributes": {
"classification": [
{
"category_id": 1,
"label_id": 1
}
],
"custom": [
{
"anything": "something"
}
],
"detection": [
{
"category_id": 1,
"label_id": 2,
"rect": {
"xmin": 22,
"ymin": 145,
"xmax": 140,
"ymax": 220
}
},
]
},
"created_at": "2017-12-27T06:25:00.394026",
"dataset_id": "1410805969256",
"dataset_item_id": 0,
"source_data": [
{
"data_type": "image/jpeg",
"data_uri": "datalake://1200123803688/20170815T044617-f20dde80-1e3b-4496-bc06-1b63b026b872",
"height": 500,
"width": 200
}
],
"organization_id": "1102940376065",
"updated_at": "2017-12-27T06:25:00.394026"
}
list_dataset_items
(organization_id: str, dataset_id: str, params: typing.Union[dict, NoneType] = None) → typing.List[dict]¶Get item list in a dataset
API reference: GET /organizations/<organization_id>/datasets/<dataset_id>/items/
dataset item list
{
"items": [
{
"attributes": {
"classification": [
{
"category_id": 1,
"label_id": 1
}
],
"custom": [
{
"anything": "something"
}
],
"detection": [
{
"category_id": 1,
"label_id": 2,
"rect": {
"xmin": 22,
"ymin": 145,
"xmax": 140,
"ymax": 220
}
},
]
},
"created_at": "2017-12-27T06:25:00.394026",
"dataset_id": "1410805969256",
"dataset_item_id": 0,
"source_data": [
{
"data_type": "image/jpeg",
"data_uri": "datalake://1200123803688/20170815T044617-f20dde80-1e3b-4496-bc06-1b63b026b872",
"height": 500,
"width": 200
}
],
"organization_id": "1102940376065",
"updated_at": "2017-12-27T06:25:00.394026"
},
...
],
"total_count": 1000,
"next_page_token": "xxx"
}
list_datasets
(organization_id: str, max_results: typing.Union[int, NoneType] = None, next_token: typing.Union[str, NoneType] = None) → typing.List[dict]¶Get datasets list
API reference: GET /organizations/<organization_id>/datasets/
response = api_client.get_dataset(organization_id='1102940376065')
[
{
"created_at": "2018-03-03T09:04:58.274324",
"dataset_id": "1377232365920",
"name": "cats-dogs",
"organization_id": "1102940376065",
"props": {
"categories": [
{
"labels": [
{
"label_id": 1,
"label": "dog"
},
{
"label_id": 2,
"label": "cat"
},
{
"label_id": 3,
"label": "others"
}
],
"category_id": 1,
"name": "cats_dogs"
}
]
},
"type": "classification",
"updated_at": "2018-03-03T09:04:58.274324"
},
{
.....
.....
},
.....
]
update_dataset_item
(organization_id: str, dataset_id: str, dataset_item_id: str, attributes: typing.Union[dict, NoneType] = None) → dict¶update a item in a dataset
API reference: PUT /organizations/<organization_id>/datasets/<dataset_id>/items/<dataset_item_id>
attributes = {
"classification": [
{
"category_id": 1,
"label_id": 1,
}
],
"custom": [
{
"anything": "something"
}
],
"detection": [
{
"category_id": 1,
"label_id": 2,
"rect": {
"xmin": 22,
"ymin": 145,
"xmax": 140,
"ymax": 220
}
},
]
}
api_client.update_dataset_item(
organization_id='1102940376065',
dataset_id='1410805969256',
dataset_item_id=0,
attributes=attributes)
{
"attributes": {
"classification": [
{
"category_id": 1,
"label_id": 1
}
],
"custom": [
{
"anything": "something"
}
],
"detection": [
{
"category_id": 1,
"label_id": 2,
"rect": {
"xmin": 22,
"ymin": 145,
"xmax": 140,
"ymax": 220
}
},
]
},
"created_at": "2017-12-27T06:25:00.394026",
"dataset_id": "1410805969256",
"dataset_item_id": 0,
"source_data": [
{
"data_type": "image/jpeg",
"data_uri": "datalake://1200123803688/20170815T044617-f20dde80-1e3b-4496-bc06-1b63b026b872",
"height": 500,
"width": 200
}
],
"organization_id": "1102940376065",
"updated_at": "2017-12-27T06:25:00.394026"
}