client_helpers
This module provides a collection of functions to interact with a lakeFS server using the lakeFS SDK. It includes functionalities to manage branches, repositories, commits, tags, and merge operations in a lakeFS instance.
Note: Users of this module should have a configured and authenticated LakeFSClient instance, which is required input to all functions.
commit ¶
commit(
client: LakeFSClient,
repository: str,
branch: str,
message: str,
metadata: dict[str, str] | None = None,
) -> Commit
Create a new commit of all uncommitted changes on the branch in the lakeFS file storage.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Repository name.
TYPE:
|
branch |
Branch name.
TYPE:
|
message |
Commit message.
TYPE:
|
metadata |
Additional metadata for the commit.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Commit
|
The created commit object of the lakeFS server. |
Source code in src/lakefs_spec/client_helpers.py
create_branch ¶
create_branch(
client: LakeFSClient, repository: str, name: str, source_branch: str, exist_ok: bool = True
) -> str
Create a branch name
in a lakeFS repository.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Repository name.
TYPE:
|
name |
Name of the branch to be created.
TYPE:
|
source_branch |
Name of the source branch the new branch is created from.
TYPE:
|
exist_ok |
Ignore creation errors if the branch already exists.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
Name of newly created or existing branch. |
RAISES | DESCRIPTION |
---|---|
ApiException
|
If a branch with the same name already exists and |
Source code in src/lakefs_spec/client_helpers.py
delete_branch ¶
Delete the specified branch from a repository.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Name of the repository from which the branch will be deleted.
TYPE:
|
branch |
Name of the branch to be deleted.
TYPE:
|
missing_ok |
Ignore errors if the requested branch does not exist in the repository.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
NotFoundException
|
If the branch does not exist in the repository and |
Source code in src/lakefs_spec/client_helpers.py
list_branches ¶
List branches in a repository.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Name of the repository for which to list branches.
TYPE:
|
prefix |
Return branches prefixed with this value.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Ref]
|
A list of qualified branches in the repository. |
Source code in src/lakefs_spec/client_helpers.py
create_repository ¶
create_repository(
client: LakeFSClient, name: str, storage_namespace: str, exist_ok: bool = True
) -> Repository
Create a new repository in the lakeFS file storage system with a specified name and storage namespace.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
name |
Name of the repository to be created. This must be unique within the lakeFS instance.
TYPE:
|
storage_namespace |
Storage namespace where the repository data will reside, typically corresponding to a bucket in object storage (e.g., S3 bucket) or a local namespace (e.g. local://
TYPE:
|
exist_ok |
Ignore creation errors if the repository already exists.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Repository
|
Repository object of the lakeFS SDK representing the newly created or existing repository. |
RAISES | DESCRIPTION |
---|---|
ApiException
|
If a repository of the same name already exists and |
Notes¶
Attempting to recreate a repository with the same name and storage namespace after previous deletion may lead to issues due to residual data, and is not recommended.
Source code in src/lakefs_spec/client_helpers.py
create_tag ¶
Create a new tag in the specified repository in the lakeFS file storage system.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Name of the repository where the tag will be created.
TYPE:
|
ref |
Commit SHA or Commit object of the commit to which the tag will point.
TYPE:
|
tag |
Name of the tag to be created.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ApiException
|
If a tag of the same name already exists and points to a different ref. |
RETURNS | DESCRIPTION |
---|---|
Ref
|
Ref object of the lakeFS SDK representing the tag. |
Source code in src/lakefs_spec/client_helpers.py
delete_tag ¶
Delete the specified tag from a repository.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Name of the repository from which the tag will be deleted.
TYPE:
|
tag |
Tag to be deleted.
TYPE:
|
Source code in src/lakefs_spec/client_helpers.py
list_tags ¶
List all the tags in the specified repository in the lakeFS file storage system.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Name of the repository from which to list the tags.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Ref]
|
Ref objects of the tag in the repository. |
Source code in src/lakefs_spec/client_helpers.py
merge ¶
Merges changes from a source reference to a target branch in a specified repository in the lakeFS file storage system. If no differences between source_ref and target_branch are found, the merge process is aborted.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Name of the repository where the merge will occur.
TYPE:
|
source_ref |
Source reference (branch name or ref/commit SHA) from which changes will be merged.
TYPE:
|
target_branch |
Target branch to which changes will be merged.
TYPE:
|
Source code in src/lakefs_spec/client_helpers.py
revert ¶
Revert the commit on the specified branch to the parent specified by parent_number.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Repository in which the specified branch is located.
TYPE:
|
branch |
Branch on which the commit should be reverted.
TYPE:
|
parent_number |
If there are multiple parents to a commit, specify to which parent the commit should be reverted.
TYPE:
|
Source code in src/lakefs_spec/client_helpers.py
reset_branch ¶
Reset the specified branch to its head.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Repository in which the specified branch is located.
TYPE:
|
branch |
Branch to reset.
TYPE:
|
Source code in src/lakefs_spec/client_helpers.py
rev_parse ¶
Resolve a commit reference to the most recent commit or traverses the specified number of parent commits on a branch in a lakeFS repository.
PARAMETER | DESCRIPTION |
---|---|
client |
lakeFS client object.
TYPE:
|
repository |
Name of the repository where the commit will be searched.
TYPE:
|
ref |
Commit SHA or Commit object (with SHA stored in its
TYPE:
|
parent |
Optionally parse a parent of
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Commit
|
Commit object representing the resolved commit in the lakeFS repository. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
|