graviti.openapi.sheet#

Interfaces about the sheet.

Module Contents#

Functions#

create_sheet(access_key, url, workspace, dataset, *, draft_number, name, schema, _avro_schema, _arrow_schema = None, record_key_strategy = None)

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

list_draft_sheets(access_key, url, workspace, dataset, *, draft_number, with_record_count = None, offset = None, limit = None)

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

list_commit_sheets(access_key, url, workspace, dataset, *, commit_id, with_record_count = None, offset = None, limit = None)

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

get_draft_sheet(access_key, url, workspace, dataset, *, draft_number, sheet, with_record_count = None, schema_format = None)

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

get_commit_sheet(access_key, url, workspace, dataset, *, commit_id, sheet, with_record_count = None, schema_format = None)

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

delete_sheet(access_key, url, workspace, dataset, *, draft_number, sheet)

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

graviti.openapi.sheet.create_sheet(access_key, url, workspace, dataset, *, draft_number, name, schema, _avro_schema, _arrow_schema=None, record_key_strategy=None)[source]#

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

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.

  • name (str) – The sheet name.

  • schema (str) – The portex schema of the sheet.

  • record_key_strategy (Optional[str]) – The __record_key generation strategy. If None, it is batch auto-increment sorting record key.

  • _avro_schema (str) –

  • _arrow_schema (Optional[str]) –

Return type

None

Examples

>>> create_sheet(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     draft_number = 1,
...     name = "val",
...     schema = '{"imports": [{"repo": "https://github.com/Project-OpenBytes/portex-standard@main", "types": [{"name": "file.Image"}]}], "type": "record", "fields": [{"name": "filename", "type": "string"}, {"name": "image", "type": "file.Image"}]}',
...     _avro_schema = '{"type": "record", "name": "root", "namespace": "cn.graviti.portex", "aliases": [], "fields": [{"name": "filename", "type": "string"}, {"name": "image", "type": {"type": "record", "name": "image", "namespace": "cn.graviti.portex.root", "aliases": [], "fields": [{"name": "checksum", "type": [null, "string"]}]}}]}',
... )
graviti.openapi.sheet.list_draft_sheets(access_key, url, workspace, dataset, *, draft_number, with_record_count=None, offset=None, limit=None)[source]#

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

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.

  • with_record_count (Optional[bool]) – Whether return the record count of each sheet. The default value of this param in OpenAPI is False.

  • 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_sheets(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     draft_number = 1,
... )
{
    "sheets": [
        {
            "name": "test",
            "created_at": "2021-03-03T18:58:10Z",
            "updated_at": "2021-03-04T18:58:10Z",
        },
        {
            "name": "trainval",
            "created_at": "2021-03-05T18:58:10Z",
            "updated_at": "2021-03-06T18:58:10Z",
        }
    ],
    "offset": 0,
    "record_size": 2,
    "total_count": 2
}
graviti.openapi.sheet.list_commit_sheets(access_key, url, workspace, dataset, *, commit_id, with_record_count=None, offset=None, limit=None)[source]#

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

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.

  • with_record_count (Optional[bool]) – Whether return the record count of each sheet. The default value of this param in OpenAPI is False.

  • 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_sheets(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     commit_id = "fde63f357daf46088639e9f57fd81cad",
... )
{
    "sheets": [
        {
            "name": "test",
            "created_at": "2021-03-03T18:58:10Z",
            "updated_at": "2021-03-04T18:58:10Z",
        },
        {
            "name": "trainval",
            "created_at": "2021-03-05T18:58:10Z",
            "updated_at": "2021-03-06T18:58:10Z",
        }
    ],
    "offset": 0,
    "record_size": 2,
    "total_count": 2
}
graviti.openapi.sheet.get_draft_sheet(access_key, url, workspace, dataset, *, draft_number, sheet, with_record_count=None, schema_format=None)[source]#

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

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.

  • with_record_count (Optional[bool]) – Whether return the record count of each sheet. The default value of this param in OpenAPI is False.

  • schema_format (Optional[str]) – Fill “JSON”/”YAML” to determine whether the schema_format of the returned schema is json or yaml. None means “JSON” format.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> get_draft_sheet(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     draft_number = 1,
...     sheet = "sheet-2",
...     with_record_count=True,
... )
{
    "name": "trainval",
    "created_at": "2021-03-05T18:58:10Z",
    "updated_at": "2021-03-06T18:58:10Z",
    "record_count": 10000,
    "schema": '{"imports": [{"repo": "https://github.com/Project-OpenBytes/...'
}
graviti.openapi.sheet.get_commit_sheet(access_key, url, workspace, dataset, *, commit_id, sheet, with_record_count=None, schema_format=None)[source]#

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

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.

  • with_record_count (Optional[bool]) – Whether return the record count of each sheet. The default value of this param in OpenAPI is False.

  • schema_format (Optional[str]) – Fill “JSON”/”YAML” to determine whether the schema_format of the returned schema is json or yaml. None means “JSON” format.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> get_commit_sheet(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     commit_id = "fde63f357daf46088639e9f57fd81cad",
...     sheet = "sheet-2",
...     with_record_count=True,
... )
{
    "name": "trainval",
    "created_at": "2021-03-05T18:58:10Z",
    "updated_at": "2021-03-06T18:58:10Z",
    "record_count": 10000,
    "schema": '{"imports": [{"repo": "https://github.com/Project-OpenBytes/...'
}
graviti.openapi.sheet.delete_sheet(access_key, url, workspace, dataset, *, draft_number, sheet)[source]#

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

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 name of the sheet to be deleted.

Return type

None

Examples

>>> delete_sheet(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     draft_number=1,
...     sheet="sheet-2"
... )