Git

class verta.code.Git(repo_url=None, branch=None, tag=None, commit_hash=None, is_dirty=None, autocapture=True, _autocapture=True)

Captures metadata about the git commit with the specified branch, tag, or commit_hash.

Parameters:
  • repo_url (str, optional) – Remote repository URL. If not provided, it will automatically be determined.

  • branch (str, optional) – Branch name. If not provided, it will automatically be determined.

  • tag (str, optional) – Commit tag. If not provided, it will automatically be determined.

  • commit_hash (str, optional) – Commit hash. If not provided, it will automatically be determined.

  • is_dirty (bool, optional) – Whether git status is dirty relative to commit_hash. If not provided, it will automatically be determined.

  • autocapture (bool, default True) – Whether to automatically capture the above parameters by reading the local git repository where this code is being executed.

Raises:

OSError – If git information cannot automatically be determined.

Variables:
  • repo_url (str or None) – Remote repository URL.

  • branch (str or None) – Branch name.

  • tag (str or None) – Commit tag.

  • commit_hash (str or None) – Commit hash.

  • is_dirty (bool) – Whether git status was dirty relative to the captured commit.

Examples

from verta.code import Git

Git()
# Git Version
#     commit d08cdf77efa4ba99199fabdc8dad8fc638f7d6f3
#     on branch main
#     with tag client-v0.18.2
#     in repo git@github.com:VertaAI/modeldb.git

Git(
    repo_url="git@github.com:VertaAI/modeldb.git",
    tag="client-v0.18.0",
)
# Git Version
#     dirty commit 26f9787d6df1fb68c26bb8d5f6d7e23a79db1aa2
#     with tag client-v0.18.0
#     in repo git@github.com:VertaAI/modeldb.git

Git(
    commit_hash="46e8f49",
)
# Git Version
#     dirty commit 46e8f49946a7a97a7413e9fc3d31907980f70474
#     in repo git@github.com:VertaAI/modeldb.git
static blob_msg_to_object(blob_msg)

Deserialize a blob protobuf message into an instance.

Parameters:

blob_msg (VersioningService_pb2.Blob) –

Returns:

instance of subclass of Blob