lakeFS Python Client (Legacy/Deprecated)
This is the legacy Python client for lakeFS, an open-source data version control system. It provides direct access to the lakeFS HTTP API, automatically generated from an OpenAPI specification. As of its last release, v1.44.0, this client has reached End-of-Life (EOL) and is officially deprecated. Users are strongly advised to migrate to the newer `lakefs-sdk` (for direct API access) or `lakefs` (for a higher-level, more Pythonic interface) packages.
Common errors
-
ModuleNotFoundError: No module named 'lakefs_client.api'
cause The `lakefs-client` package is not installed or the environment is not active.fixEnsure the package is installed: `pip install lakefs-client`. -
lakefs_client.ApiException: (401) Reason: Unauthorized
cause Incorrect lakeFS access credentials (access key ID or secret access key) or an invalid host endpoint.fixVerify that `LAKEFS_ENDPOINT`, `LAKEFS_ACCESS_KEY_ID`, and `LAKEFS_SECRET_ACCESS_KEY` environment variables are correctly set, or that the `Configuration` object is initialized with valid `host`, `username`, and `password`. -
AttributeError: 'module' object has no attribute 'Configuration'
cause Attempting to import `Configuration` directly from `lakefs_client` instead of accessing it as `lakefs_client.Configuration`.fixChange `from lakefs_client import Configuration` to `import lakefs_client; configuration = lakefs_client.Configuration()`.
Warnings
- breaking The `lakefs-client` package is deprecated and has reached End-of-Life (EOL) with its last release, v1.44.0. It will no longer receive updates, new features, or compatibility guarantees for future lakeFS server versions beyond 1.x.
- gotcha The `lakefs-client` SDK is auto-generated and does not offer strong interface guarantees, meaning methods and models might change between minor versions in a non-backward-compatible way for source code.
- gotcha Authentication for `lakefs-client` is less flexible than newer SDKs, typically requiring explicit `username` and `password` or `api_key` configuration. It lacks automatic inference from environment variables or `~/.lakectl.yaml` files without manual setup.
Install
-
pip install lakefs-client
Imports
- Configuration
from lakefs_client import Configuration
import lakefs_client configuration = lakefs_client.Configuration()
- RepositoriesApi
from lakefs_client import RepositoriesApi
from lakefs_client.api import repositories_api
- Repository
from lakefs_client.models import Repository
from lakefs_client.model.repository import Repository
Quickstart
import os
import lakefs_client
from lakefs_client.api import repositories_api
# Configure HTTP basic authorization (replace with your lakeFS endpoint and credentials)
configuration = lakefs_client.Configuration(
host=os.environ.get('LAKEFS_ENDPOINT', 'http://localhost/api/v1'),
username=os.environ.get('LAKEFS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY_ID'),
password=os.environ.get('LAKEFS_SECRET_ACCESS_KEY', 'YOUR_SECRET_ACCESS_KEY')
)
# Create an instance of the API class
api_client = lakefs_client.ApiClient(configuration)
api_instance = repositories_api.RepositoriesApi(api_client)
try:
# List repositories
repos = api_instance.list_repositories()
print("Existing Repositories:")
for repo in repos.results:
print(f"- {repo.id}")
except lakefs_client.ApiException as e:
print(f"Exception when calling RepositoriesApi->list_repositories: {e}")
print("Make sure your lakeFS server is running and credentials are correct.")