Skip to content

hopsworks.core.git_api #

[source] GitApi #

[source] clone #

clone(
    url: str,
    path: str,
    provider: Literal["GitHub", "GitLab", "BitBucket"]
    | None = None,
    branch: str = None,
) -> git_repo.GitRepo

Clone a new Git Repo in to Hopsworks Filesystem.

import hopsworks

project = hopsworks.login()

git_api = project.get_git_api()

git_repo = git_api.clone("https://github.com/logicalclocks/hops-examples.git", "Resources", "GitHub")
PARAMETER DESCRIPTION
url

URL to the git repository.

TYPE: str

path

Path in Hopsworks Filesystem to clone the repo to.

TYPE: str

provider

The git provider where the repo is currently hosted.

TYPE: Literal['GitHub', 'GitLab', 'BitBucket'] | None DEFAULT: None

branch

The branch to clone, defaults to the configured default branch.

TYPE: str DEFAULT: None

RETURNS DESCRIPTION
git_repo.GitRepo

Git repository object.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

[source] get_repos #

get_repos() -> list[git_repo.GitRepo]

Get the existing Git repositories.

RETURNS DESCRIPTION
list[git_repo.GitRepo]

List of git repository objects.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

[source] get_providers #

get_providers() -> list[git_provider.GitProvider]

Get the configured Git providers.

RETURNS DESCRIPTION
list[git_provider.GitProvider]

List of git provider objects.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

[source] get_provider #

get_provider(
    provider: Literal["GitHub", "GitLab", "BitBucket"],
    host: str = None,
) -> git_provider.GitProvider | None

Get the configured Git provider.

PARAMETER DESCRIPTION
provider

Name of the git provider.

TYPE: Literal['GitHub', 'GitLab', 'BitBucket']

host

Optional host for the git provider, e.g., "github.com" for GitHub, "gitlab.com" for GitLab, "bitbucket.org" for BitBucket.

TYPE: str DEFAULT: None

RETURNS DESCRIPTION
git_provider.GitProvider | None

The git provider or None if it does not exist.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

[source] set_provider #

set_provider(
    provider: Literal["GitHub", "GitLab", "BitBucket"],
    username: str,
    token: str,
    host: str = None,
)

Configure a Git provider.

import hopsworks

project = hopsworks.login()

git_api = project.get_git_api()

git_api.set_provider("GitHub", "my_user", "my_token", host="github.com")
PARAMETER DESCRIPTION
provider

Name of the git provider.

TYPE: Literal['GitHub', 'GitLab', 'BitBucket']

username

Username for the git provider service.

TYPE: str

token

Token to set for the git provider service.

TYPE: str

host

Host for the git provider, e.g., "github.com" for GitHub, "gitlab.com" for GitLab, "bitbucket.org" for BitBucket.

TYPE: str DEFAULT: None

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

[source] get_repo #

get_repo(
    name: str, path: str = None
) -> git_repo.GitRepo | None

Get the cloned Git repository.

PARAMETER DESCRIPTION
name

Name of the git repository.

TYPE: str

path

Optional path to specify if multiple git repositories with the same name exist in the project.

TYPE: str DEFAULT: None

RETURNS DESCRIPTION
git_repo.GitRepo | None

The git repository or None if it does not exist.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.