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.
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.
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")
draft = dataset_client.get_draft(draft_number=1)
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 = "***"
commit = dataset_client.get_commit(commit_id)
commits = dataset_client.list_commits()
# checkout to the draft. dataset_client.checkout(draft_number=draft_number) # checkout to the commit. dataset_client.checkout(revision=commit_id)
Here, revision is the information to locate the specific commit, which can be the commit id, the branch, or the tag.