graviti.openapi.branch#

Interfaces about the branch.

Module Contents#

Functions#

create_branch(access_key, url, workspace, dataset, *, name, revision)

Execute the OpenAPI POST /v2/datasets/{workspace}/{dataset}/branches.

list_branches(access_key, url, workspace, dataset, *, offset = None, limit = None)

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/branches.

get_branch(access_key, url, workspace, dataset, *, branch)

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/branches/{branch}.

delete_branch(access_key, url, workspace, dataset, *, branch)

Execute the OpenAPI DELETE /v2/datasets/{workspace}/{dataset}/branches/{branch}.

graviti.openapi.branch.create_branch(access_key, url, workspace, dataset, *, name, revision)[source]#

Execute the OpenAPI POST /v2/datasets/{workspace}/{dataset}/branches.

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.

  • name (str) – The name of the branch.

  • revision (str) – The information to locate the specific commit, which can be the commit id, the branch name, or the tag name.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> create_branch(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     name="branch-1",
...     revision="main"
... )
{
    "name": "main",
    "commit_id": "fde63f357daf46088639e9f57fd81cad",
    "parent_commit_id": "f68b1375454f459b8a486b8d1f4d9ddb",
    "title": "first commit",
    "description": "desc",
    "committer": "graviti-example",
    "committed_at": "2021-03-03T18:58:10Z"
}
graviti.openapi.branch.list_branches(access_key, url, workspace, dataset, *, offset=None, limit=None)[source]#

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/branches.

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.

  • 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_branches(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST"
... )
{
   "branches": [
       {
           "name": "main",
           "commit_id": "fde63f357daf46088639e9f57fd81cad",
           "parent_commit_id": "f68b1375454f459b8a486b8d1f4d9ddb",
           "title": "first commit",
           "description": "desc",
           "committer": "graviti-example",
           "committed_at": "2021-03-03T18:58:10Z"
       }
   ],
   "offset": 0,
   "record_size": 1,
   "total_count": 1
}
graviti.openapi.branch.get_branch(access_key, url, workspace, dataset, *, branch)[source]#

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/branches/{branch}.

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.

  • branch (str) – The name of the branch.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> get_branch(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     branch="main",
... )
{
    "name": "main",
    "commit_id": "fde63f357daf46088639e9f57fd81cad",
    "parent_commit_id": "f68b1375454f459b8a486b8d1f4d9ddb",
    "title": "first commit",
    "description": "desc",
    "committer": "graviti-example",
    "committed_at": "2021-03-03T18:58:10Z"
}
graviti.openapi.branch.delete_branch(access_key, url, workspace, dataset, *, branch)[source]#

Execute the OpenAPI DELETE /v2/datasets/{workspace}/{dataset}/branches/{branch}.

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.

  • branch (str) – The name of the branch.

Return type

None

Examples

>>> delete_branch(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     branch="branch-1",
... )