https://lakefs.io/ logo
#help
Title
# help
b

Bill Li

02/22/2024, 3:35 PM
When interacting with objects in lakeFS using boto, is there a way to commit to LakeFS using the python lakefs SDK?
i

Idan Novogroder

02/22/2024, 3:55 PM
Hey Bill, Yes, here's a short example:
Copy code
from lakefs_client import LakeFSClient
from lakefs_client.models import CommitCreation

# Initialize the lakeFS client
client = LakeFSClient(
    configuration={
        "host": "<http://lakefs.example.com/api/v1|http://lakefs.example.com/api/v1>",
        "access_key": "YOUR_ACCESS_KEY",
        "secret_key": "YOUR_SECRET_KEY"
    }
)

# Specify the repository and branch you've been working on
repository_name = 'your-repository'
branch_name = 'your-branch'

# Create a commit with the changes
commit_response = client.commits.commit(
    repository=repository_name,
    branch=branch_name,
    commit_creation=CommitCreation(
        message="Describe the changes you made",
        metadata={"key": "value"}  # Optional additional metadata about the commit
    )
)
lakefs 1
b

Bill Li

02/22/2024, 4:10 PM
Thank you!
lakefs 1
i

Idan Novogroder

02/22/2024, 5:22 PM
One last thing, You can also use the high-level Python SDK, which should provide a smoother experience.
4 Views