Draft and Commit#

The version control is based on the draft and commit.

Similar with Git, a commit is a version of a dataset, which contains the changes compared with the former commit.

Unlike Git, a draft is a new concept which represents a workspace in which changing the dataset is allowed.

In TensorBay SDK, the dataset client supplies the function of version control.


from tensorbay import GAS

# Please visit `https://gas.graviti.com/tensorbay/developer` to get the AccessKey.
dataset_client = gas.create_dataset("<DATASET_NAME>")

Create Draft#

TensorBay SDK supports creating the draft straightforwardly, which is based on the current branch. Note that currently there can be only one open draft in each branch.


Then the dataset client will change the status to “draft” and store the draft number. The draft number will be auto-increasing every time a draft is created.

is_draft = dataset_client.status.is_draft
# is_draft = True (True for draft, False for commit)
draft_number = dataset_client.status.draft_number
# draft_number = 1
branch_name = dataset_client.status.branch_name
# branch_name = main

Also, TensorBay SDK supports creating a draft based on a given branch.

dataset_client.create_draft("draft-1", branch_name="main")

List Drafts#

The draft number can be found through listing drafts.

status includes “OPEN”, “CLOSED”, “COMMITTED” and None where None means listing drafts in all status. branch_name refers to the branch name of the draft to be listed.

drafts = dataset_client.list_drafts(status="CLOSED", branch_name="branch-1")

Get Draft#

draft = dataset_client.get_draft(draft_number=1)

Commit Draft#

After the commit, the draft will be closed.

dataset_client.commit("commit-1", "commit description")
is_draft = dataset_client.status.is_draft
# is_draft = False (True for draft, False for commit)
commit_id = dataset_client.status.commit_id
# commit_id = "***"

Get Commit#

commit = dataset_client.get_commit(commit_id)

List Commits#

commits = dataset_client.list_commits()


# checkout to the draft.
# checkout to the commit.


Here, revision is the information to locate the specific commit, which can be the commit id, the branch, or the tag.