tensorbay.client.version

TensorBay dataset version control related classes.

class tensorbay.client.version.VersionControlClient(dataset_id: str, gas: GAS, *, status: tensorbay.client.status.Status)[source]

Bases: object

TensorBay dataset version control client.

Parameters
  • dataset_id – Dataset ID.

  • gas – The initial client to interact between local and TensorBay.

  • status – The version control status of the dataset.

property dataset_id: str

Return the TensorBay dataset ID.

Returns

The TensorBay dataset ID.

property status: tensorbay.client.status.Status

Return the status of the dataset client.

Returns

The status of the dataset client.

checkout(revision: Optional[str] = None, draft_number: Optional[int] = None) None[source]

Checkout to commit or draft.

Parameters
  • revision – The information to locate the specific commit, which can be the commit id, the branch, or the tag.

  • draft_number – The draft number.

Raises

TypeError – When both commit and draft number are provided or neither.

commit(title: str, description: str = '', *, tag: Optional[str] = None) None[source]

Commit the draft.

Commit the draft based on the draft number stored in the dataset client. Then the dataset client will change the status to “commit” and store the branch name and commit id.

Parameters
  • title – The commit title.

  • description – The commit description.

  • tag – A tag for current commit.

create_draft(title: str, description: str = '', branch_name: Optional[str] = None) int[source]

Create a draft.

Create a draft with the branch name. If the branch name is not given, create a draft based on the branch name stored in the dataset client. Then the dataset client will change the status to “draft” and store the branch name and draft number.

Parameters
  • title – The draft title.

  • description – The draft description.

  • branch_name – The branch name.

Returns

The draft number of the created draft.

Raises

StatusError – When creating the draft without basing on a branch.

get_draft(draft_number: Optional[int] = None) tensorbay.client.struct.Draft[source]

Get the certain draft with the given draft number.

Get the certain draft with the given draft number. If the draft number is not given, get the draft based on the draft number stored in the dataset client.

Parameters

draft_number – The required draft number. If is not given, get the current draft.

Returns

The Draft instance with the given number.

Raises
  • TypeError – When the given draft number is illegal.

  • ResourceNotExistError – When the required draft does not exist.

list_drafts(status: Optional[str] = 'OPEN', branch_name: Optional[str] = None) tensorbay.client.lazy.PagingList[tensorbay.client.struct.Draft][source]

List all the drafts.

Parameters
  • status – The draft status which includes “OPEN”, “CLOSED”, “COMMITTED”, “ALL” and None. where None means listing open drafts.

  • branch_name – The branch name.

Returns

The PagingList of drafts.

update_draft(draft_number: Optional[int] = None, *, title: Optional[str] = None, description: Optional[str] = None) None[source]

Update the draft.

Parameters
  • draft_number – The updated draft number. If is not given, update the current draft.

  • title – The title of the draft.

  • description – The description of the draft.

close_draft(number: int) None[source]

Close the draft.

Parameters

number – The draft number.

Raises

StatusError – When closing the current draft.

get_commit(revision: Optional[str] = None) tensorbay.client.struct.Commit[source]

Get the certain commit with the given revision.

Get the certain commit with the given revision. If the revision is not given, get the commit based on the commit id stored in the dataset client.

Parameters

revision – The information to locate the specific commit, which can be the commit id, the branch name, or the tag name. If is not given, get the current commit.

Returns

The Commit instance with the given revision.

Raises
  • TypeError – When the given revision is illegal.

  • ResourceNotExistError – When the required commit does not exist.

list_commits(revision: Optional[str] = None) tensorbay.client.lazy.PagingList[tensorbay.client.struct.Commit][source]

List the commits.

Parameters

revision – The information to locate the specific commit, which can be the commit id, the branch name, or the tag name. If is given, list the commits before the given commit. If is not given, list the commits before the current commit.

Raises

TypeError – When the given revision is illegal.

Returns

The PagingList of commits.

create_branch(name: str, revision: Optional[str] = None) None[source]

Create a branch.

Create a branch based on a commit with the given revision. If the revision is not given, create a branch based on the commit id stored in the dataset client. Then the dataset client will change the status to “commit” and store the branch name and the commit id.

Parameters
  • name – The branch name.

  • revision – The information to locate the specific commit, which can be the commit id, the branch name, or the tag name. If the revision is not given, create the branch based on the current commit.

get_branch(name: str) tensorbay.client.struct.Branch[source]

Get the branch with the given name.

Parameters

name – The required branch name.

Returns

The Branch instance with the given name.

Raises
  • TypeError – When the given branch is illegal.

  • ResourceNotExistError – When the required branch does not exist.

list_branches() tensorbay.client.lazy.PagingList[tensorbay.client.struct.Branch][source]

List the information of branches.

Returns

The PagingList of branches.

delete_branch(name: str) None[source]

Delete a branch.

Delete the branch with the given branch name. Note that deleting the branch with the name which is stored in the current dataset client is not allowed.

Parameters

name – The name of the branch to be deleted.

Raises

StatusError – When deleting the current branch.

create_tag(name: str, revision: Optional[str] = None) None[source]

Create a tag for a commit.

Create a tag for a commit with the given revision. If the revision is not given, create a tag based on the commit id stored in the dataset client.

Parameters
  • name – The tag name to be created for the specific commit.

  • revision – The information to locate the specific commit, which can be the commit id, the branch name, or the tag name. If the revision is not given, create the tag for the current commit.

get_tag(name: str) tensorbay.client.struct.Tag[source]

Get the certain tag with the given name.

Parameters

name – The required tag name.

Returns

The Tag instance with the given name.

Raises
  • TypeError – When the given tag is illegal.

  • ResourceNotExistError – When the required tag does not exist.

list_tags() tensorbay.client.lazy.PagingList[tensorbay.client.struct.Tag][source]

List the information of tags.

Returns

The PagingList of tags.

delete_tag(name: str) None[source]

Delete a tag.

Parameters

name – The tag name to be deleted for the specific commit.