graviti.openapi.record#

Interfaces about the record.

Module Contents#

Functions#

list_draft_records(access_key, url, workspace, dataset, *, draft_number, sheet, columns = None, sort = None, offset = None, limit = None)

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/drafts/{draft_number} /sheets/{sheet}/records.

list_commit_records(access_key, url, workspace, dataset, *, commit_id, sheet, columns = None, sort = None, offset = None, limit = None)

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/commits/{commit_id}/sheets /{sheet}/records.

update_records(access_key, url, workspace, dataset, *, draft_number, sheet, records)

Execute the OpenAPI PATCH /v2/datasets/{workspace}/{dataset}/drafts/{draft_number} /sheets/{sheet}/records.

add_records(access_key, url, workspace, dataset, *, draft_number, sheet, records, strategy_arguments = None)

Execute the OpenAPI POST /v2/datasets/{workspace}/{dataset}/drafts/{draft_number} /sheets/{sheet}/records.

delete_records(access_key, url, workspace, dataset, *, draft_number, sheet, record_keys)

Execute the OpenAPI DELETE /v2/datasets/{workspace}/{dataset}/drafts/{draft_number} /sheets/{sheet}/records.

graviti.openapi.record.list_draft_records(access_key, url, workspace, dataset, *, draft_number, sheet, columns=None, sort=None, offset=None, limit=None)[source]#

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/drafts/{draft_number} /sheets/{sheet}/records.

Parameters
  • access_key (str) – User’s access key.

  • url (str) – The URL of the graviti website.

  • workspace (str) – The workspace of the dataset.

  • dataset (str) – Name of the dataset, unique for a user.

  • draft_number (int) – The draft number.

  • sheet (str) – The sheet name.

  • columns (Optional[str]) – The string of column names separated by ,. Multiple indexes can be expressed using .. None means to get all columns.

  • sort (graviti.utility.typing.SortParam) – The column and the direction the list result sorted by.

  • offset (Optional[int]) – The offset of the page. The default value of this param in OpenAPIv2 is 0.

  • limit (Optional[int]) – The limit of the page. The default value of this param in OpenAPIv2 is 128.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> list_draft_records(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     draft_number=1,
...     sheet="train",
... )
{
    "records": [
        {
            "__record_key": "123750493121329585",
            "filename": "0000f77c-6257be58.jpg",
            "image": {
                "url": "https://content-store-prod-vers",
                "checksum": "dcc197970e607f7576d978972f6fb312911ce005"
            },
            "attribute": {
                "weather": "clear",
                "scene": "city street",
                "timeofday": "daytime"
            },
            "box2ds": [
                {
                    "xmin": 1125.902264,
                    "xmax": 1156.978645,
                    "ymin": 133.184488,
                    "ymax": 210.875445,
                    "category": "traffic light",
                    "attribute": {
                        "occluded": false,
                        "truncated": false,
                        "trafficLightColor": "G"
                    }
                },
                {
                    "xmin": 1156.978645,
                    "xmax": 1191.50796,
                    "ymin": 136.637417,
                    "ymax": 210.875443,
                    "category": "traffic light",
                    "attribute": {
                        "occluded": false,
                        "truncated": false,
                        "trafficLightColor": "G"
                    }
                },
        ...
            ]
        },
        ...(total 128 items)
    ],
    "offset": 0,
    "record_size": 128,
    "total_count": 70000
}
graviti.openapi.record.list_commit_records(access_key, url, workspace, dataset, *, commit_id, sheet, columns=None, sort=None, offset=None, limit=None)[source]#

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/commits/{commit_id}/sheets /{sheet}/records.

Parameters
  • access_key (str) – User’s access key.

  • url (str) – The URL of the graviti website.

  • workspace (str) – The workspace of the dataset.

  • dataset (str) – Name of the dataset, unique for a user.

  • commit_id (str) – The commit id.

  • sheet (str) – The sheet name.

  • columns (Optional[str]) – The string of column names separated by ,. Multiple indexes can be expressed using .. None means to get all columns.

  • sort (graviti.utility.typing.SortParam) – The column and the direction the list result sorted by.

  • offset (Optional[int]) – The offset of the page. The default value of this param in OpenAPIv2 is 0.

  • limit (Optional[int]) – The limit of the page. The default value of this param in OpenAPIv2 is 128.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> list_commit_records(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     commit_id="fde63f357daf46088639e9f57fd81cad",
...     sheet="train",
... )
{
    "records": [
        {
            "__record_key": "123750493121329585",
            "filename": "0000f77c-6257be58.jpg",
            "image": {
                "url": "https://content-store-prod-vers",
                "checksum": "dcc197970e607f7576d978972f6fb312911ce005"
            },
            "attribute": {
                "weather": "clear",
                "scene": "city street",
                "timeofday": "daytime"
            },
            "box2ds": [
                {
                    "xmin": 1125.902264,
                    "xmax": 1156.978645,
                    "ymin": 133.184488,
                    "ymax": 210.875445,
                    "category": "traffic light",
                    "attribute": {
                        "occluded": false,
                        "truncated": false,
                        "trafficLightColor": "G"
                    }
                },
                {
                    "xmin": 1156.978645,
                    "xmax": 1191.50796,
                    "ymin": 136.637417,
                    "ymax": 210.875443,
                    "category": "traffic light",
                    "attribute": {
                        "occluded": false,
                        "truncated": false,
                        "trafficLightColor": "G"
                    }
                },
        ...
            ]
        },
        ...(total 128 items)
    ],
    "offset": 0,
    "record_size": 128,
    "total_count": 70000
}
graviti.openapi.record.update_records(access_key, url, workspace, dataset, *, draft_number, sheet, records)[source]#

Execute the OpenAPI PATCH /v2/datasets/{workspace}/{dataset}/drafts/{draft_number} /sheets/{sheet}/records.

Parameters
  • access_key (str) – User’s access key.

  • url (str) – The URL of the graviti website.

  • workspace (str) – The workspace of the dataset.

  • dataset (str) – Name of the dataset, unique for a user.

  • draft_number (int) – The draft number.

  • sheet (str) – The sheet name.

  • records (Union[List[Dict[str, Any]], Tuple[Dict[str, Any], Ellipsis]]) – The records to be updated.

Return type

None

Examples

>>> update_records(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "OxfordIIITPet",
...     draft_number=1,
...     sheet="train",
...     records=[
...         {
...             "__record_key": "123750493121329585",
...             "filename": "0000f77c-6257be58.jpg",
...             "image": {
...                 "checksum": "dcc197970e607f7576d978972f6fb312911ce005"
...             },
...             "attribute": {
...                 "weather": "clear",
...                 "scene": "city street",
...                 "timeofday": "daytime"
...             },
...         },
...         {
...             "__record_key": "123750493121329585",
...             "filename": "0000f77c-62c2a288.jpg",
...             "image": {
...                 "checksum": "dcc197970e607f7576d978972f6fb2a2881ce004"
...             },
...             "attribute": {
...                 "weather": "clear",
...                 "scene": "highway",
...                 "timeofday": "dawn/dusk"
...             },
...         }
...     ],
... )
graviti.openapi.record.add_records(access_key, url, workspace, dataset, *, draft_number, sheet, records, strategy_arguments=None)[source]#

Execute the OpenAPI POST /v2/datasets/{workspace}/{dataset}/drafts/{draft_number} /sheets/{sheet}/records.

Parameters
  • access_key (str) – User’s access key.

  • url (str) – The URL of the graviti website.

  • workspace (str) – The workspace of the dataset.

  • dataset (str) – Name of the dataset, unique for a user.

  • draft_number (int) – The draft number.

  • sheet (str) – The sheet name.

  • records (Union[List[Dict[str, Any]], Tuple[Dict[str, Any], Ellipsis]]) – The records to be added.

  • strategy_arguments (Optional[Dict[str, Any]]) – Arguments required by the __record_key generation strategy of the sheet.

Return type

None

Examples

>>> add_records(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "OxfordIIITPet",
...     draft_number=1,
...     sheet="train",
...     records=[
...         {
...             "filename": "0000f77c-6257be58.jpg",
...             "image": {
...                 "checksum": "dcc197970e607f7576d978972f6fb312911ce005"
...             },
...             "attribute": {
...                 "weather": "clear",
...                 "scene": "city street",
...                 "timeofday": "daytime"
...             },
...         },
...         {
...             "filename": "0000f77c-62c2a288.jpg",
...             "image": {
...                 "checksum": "dcc197970e607f7576d978972f6fb2a2881ce004"
...             },
...             "attribute": {
...                 "weather": "clear",
...                 "scene": "highway",
...                 "timeofday": "dawn/dusk"
...             },
...         }
...     ],
... )
graviti.openapi.record.delete_records(access_key, url, workspace, dataset, *, draft_number, sheet, record_keys)[source]#

Execute the OpenAPI DELETE /v2/datasets/{workspace}/{dataset}/drafts/{draft_number} /sheets/{sheet}/records.

Parameters
  • access_key (str) – User’s access key.

  • url (str) – The URL of the graviti website.

  • workspace (str) – The workspace of the dataset.

  • dataset (str) – Name of the dataset, unique for a user.

  • draft_number (int) – The draft number.

  • sheet (str) – The sheet name.

  • record_keys (List[str]) – The keys of the records to be deleted.

Return type

None

Examples

>>> delete_records(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "OxfordIIITPet",
...     draft_number=1,
...     sheet="train",
...     record_keys=["123750493121329585", "123750493121329586"],
... )