tensorbay.client.version#

Related methods of the TensorBay version control.

class tensorbay.client.version.VersionControlMixin[source]#

Bases: object

A mixin class supporting version control methods.

checkout(revision=None, draft_number=None)[source]#

Checkout to commit or draft.

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

  • draft_number (Optional[int]) – The draft number.

Raises

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

Return type

None

commit(title, description='', *, tag=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 (str) – The commit title.

  • description (str) – The commit description.

  • tag (Optional[str]) – A tag for current commit.

Return type

None

create_draft(title, description='', branch_name=None)[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 (str) – The draft title.

  • description (str) – The draft description.

  • branch_name (Optional[str]) – The branch name.

Returns

The draft number of the created draft.

Raises

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

Return type

int

get_draft(draft_number=None)[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 (Optional[int]) – 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.

Return type

tensorbay.client.struct.Draft

list_drafts(status='OPEN', branch_name=None)[source]#

List all the drafts.

Parameters
  • status (Optional[str]) – The draft status which includes “OPEN”, “CLOSED”, “COMMITTED”, “ALL” and None. where None means listing open drafts.

  • branch_name (Optional[str]) – The branch name.

Returns

The PagingList of drafts.

Return type

tensorbay.client.lazy.PagingList[tensorbay.client.struct.Draft]

update_draft(draft_number=None, *, title=None, description=None)[source]#

Update the draft.

Parameters
  • draft_number (Optional[int]) – The updated draft number. If is not given, update the current draft.

  • title (Optional[str]) – The title of the draft.

  • description (Optional[str]) – The description of the draft.

Return type

None

close_draft(number)[source]#

Close the draft.

Parameters

number (int) – The draft number.

Raises

StatusError – When closing the current draft.

Return type

None

get_commit(revision=None)[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 (Optional[str]) – 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.

Return type

tensorbay.client.struct.Commit

list_commits(revision=None)[source]#

List the commits.

Parameters

revision (Optional[str]) – 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.

Return type

tensorbay.client.lazy.PagingList[tensorbay.client.struct.Commit]

create_branch(name, revision=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 (str) – The branch name.

  • revision (Optional[str]) – 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.

Return type

None

get_branch(name)[source]#

Get the branch with the given name.

Parameters

name (str) – 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.

Return type

tensorbay.client.struct.Branch

list_branches()[source]#

List the information of branches.

Returns

The PagingList of branches.

Return type

tensorbay.client.lazy.PagingList[tensorbay.client.struct.Branch]

delete_branch(name)[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 (str) – The name of the branch to be deleted.

Raises

StatusError – When deleting the current branch.

Return type

None

create_tag(name, revision=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 (str) – The tag name to be created for the specific commit.

  • revision (Optional[str]) – 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.

Return type

None

get_tag(name)[source]#

Get the certain tag with the given name.

Parameters

name (str) – 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.

Return type

tensorbay.client.struct.Tag

list_tags()[source]#

List the information of tags.

Returns

The PagingList of tags.

Return type

tensorbay.client.lazy.PagingList[tensorbay.client.struct.Tag]

delete_tag(name)[source]#

Delete a tag.

Parameters

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

Return type

None

class tensorbay.client.version.JobMixin[source]#

Bases: object

A mixin class supporting asynchronous jobs.

delete_job(job_id)[source]#

Delete a Job.

Parameters

job_id (str) – The Job id.

Return type

None

class tensorbay.client.version.SquashAndMerge(client, dataset_id, status, draft_getter)[source]#

Bases: tensorbay.client.version.JobMixin

This class defines SquashAndMerge.

Parameters
Return type

None

create_job(title='', description='', *, draft_title, source_branch_name, target_branch_name=None, draft_description='', strategy='abort')[source]#

Create a SquashAndMergeJob.

Squash commits in source branch, then merge into target branch by creating a new draft. If the target branch name is not given, the draft will be based on the branch name stored in the dataset client. And during merging, the conflicts between branches can be resolved in three different strategies: “abort”, “override” and “skip”.

Parameters
  • title (str) – The SquashAndMergeJob title.

  • description (str) – The SquashAndMergeJob description.

  • draft_title (str) – The draft title.

  • source_branch_name (str) – The name of the branch to be squashed.

  • target_branch_name (Optional[str]) – The target branch name of the merge operation.

  • draft_description (str) – The draft description.

  • strategy (Optional[str]) –

    The strategy of handling the branch conflict. There are three options:

    1. ”abort”: abort the opetation;

    2. ”override”: the squashed branch will override the target branch;

    3. ”skip”: keep the origin branch.

Raises

StatusError – When squashing and merging without basing on a branch.

Returns

The SquashAndMergeJob.

Return type

tensorbay.client.job.SquashAndMergeJob

get_job(job_id)[source]#

Get a SquashAndMergeJob.

Parameters

job_id (str) – The SquashAndMergeJob id.

Returns

The SquashAndMergeJob.

Return type

tensorbay.client.job.SquashAndMergeJob

list_jobs(status=None)[source]#

List the SquashAndMergeJob.

Parameters

status (Optional[str]) – The SquashAndMergeJob status which includes “QUEUING”, “PROCESSING”, “SUCCESS”, “FAIL”, “ABORT” and None. None means all kinds of status.

Returns

The PagingList of SquashAndMergeJob.

Return type

tensorbay.client.lazy.PagingList[tensorbay.client.job.SquashAndMergeJob]

class tensorbay.client.version.BasicSearch(client, dataset_id, status, is_fusion)[source]#

Bases: tensorbay.client.version.JobMixin

This class defines BasicSearch.

Parameters
Return type

None

create_job(title='', description='', *, conjunction, filters, unit='file')[source]#

Create a BasicSearchJob.

Parameters
  • title (str) – The BasicSearchJob title.

  • description (str) – The BasicSearchJob description.

  • conjunction (str) – The logical conjunction between search filters, which includes “and” and “or”.

  • filters (List[Tuple[Any, ...]]) – The list of basic search criteria.

  • unit (str) –

    The unit of basic search. There are two options:

    1. ”file”: get the data that meets search filters;

    2. ”frame”: if at least one data in a frame meets search filters, all data in

      the frame will be get. This option only works on fusion dataset.

Returns

The BasicSearchJob.

Return type

tensorbay.client.job.BasicSearchJob

get_job(job_id)[source]#

Get a BasicSearchJob.

Parameters

job_id (str) – The BasicSearchJob id.

Returns

The BasicSearchJob.

Return type

tensorbay.client.job.BasicSearchJob

list_jobs(status=None)[source]#

List the BasicSearchJob.

Parameters

status (Optional[str]) – The BasicSearchJob status which includes “QUEUING”, “PROCESSING”, “SUCCESS”, “FAIL”, “ABORT” and None. None means all kinds of status.

Returns

The PagingList of BasicSearchJob.

Return type

tensorbay.client.lazy.PagingList[tensorbay.client.job.BasicSearchJob]