graviti.manager.commit#

The implementation of the Commit and CommitManager.

Module Contents#

Classes#

Commit

This class defines the structure of a commit.

NamedCommit

This class defines the structure of a named commit.

CommitManager

This class defines the operations on the commit in Graviti.

class graviti.manager.commit.Commit(dataset, commit_id)[source]#

Bases: graviti.manager.sheets.Sheets

This class defines the structure of a commit.

Parameters
commit_id#

The commit id of the commit.

parent[source]#

The parent commit of the commit.

title[source]#

The title of the commit.

description[source]#

The description of the commit.

committer[source]#

The committer of the commit.

committed_at[source]#

The commit time of the commit.

classmethod from_response(cls, dataset, response)[source]#

Create a Commit instance from python dict.

Parameters
  • dataset (graviti.manager.dataset.Dataset) – The dataset of the commit.

  • response (Dict[str, Any]) –

    A python dict containing all the information of the commit:

    {
        "commit_id": <str>
        "parent_commit_id": <Optional[str]>
        "title": <str>
        "description": <str>
        "committer":  <str>
        "committed_at": <str>
    }
    

  • cls (Type[_C]) –

Returns

A Commit instance created from the input python dict.

Return type

_C

class graviti.manager.commit.NamedCommit(dataset, name, commit_id)[source]#

Bases: Commit

This class defines the structure of a named commit.

NamedCommit is the base class of Branch and Tag.

Parameters
  • dataset (graviti.manager.dataset.Dataset) – Class Dataset instance.

  • name (str) – The name of the named commit.

  • commit_id (Optional[str]) – The commit id.

classmethod from_response(cls, dataset, response)[source]#

Create a NamedCommit instance from python dict.

Parameters
  • dataset (graviti.manager.dataset.Dataset) – The dataset of the NamedCommit.

  • response (Dict[str, Any]) –

    A python dict containing all the information of the NamedCommit:

    {
        "name": <str>
        "commit_id": <Optional[str]>
        "parent_commit_id": <Optional[str]>
        "title": <str>
        "description": <str>
        "committer":  <str>
        "committed_at": <str>
    }
    

  • cls (Type[_NC]) –

Returns

A NamedCommit instance created from the input python dict.

Return type

_NC

class graviti.manager.commit.CommitManager(dataset)[source]#

This class defines the operations on the commit in Graviti.

Parameters

dataset (graviti.manager.dataset.Dataset) – Dataset instance.

get(self, revision=CURRENT_COMMIT)[source]#

Get the certain commit with the given revision.

Parameters

revision (str) – The information to locate the specific commit, which can be the commit id, the branch name, or the tag name. The default value is the current commit of the dataset.

Raises

NoCommitsError – When revision is not given and the commit id of current dataset is None, or when the given branch has no commit history yet.

Returns

The Commit instance with the given revision.

Return type

Commit

list(self, revision=CURRENT_COMMIT)[source]#

List the commits.

Parameters

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

Returns

The LazyPagingList of commits instances.

Return type

Union[graviti.manager.lazy.LazyPagingList[Commit], List[Optional[Commit]]]