Ayush Paudel
04/27/2023, 7:46 AMIdan Novogroder
04/27/2023, 8:40 AMlakectl fs download
is what you are looking for in lakectl
https://docs.lakefs.io/reference/cli.html#lakectl-fs-downloadAyush Paudel
04/27/2023, 12:04 PMIdan Novogroder
04/27/2023, 12:38 PMos.chdir("your_new_download_path")
Ayush Paudel
04/27/2023, 12:39 PMIdan Novogroder
04/27/2023, 12:40 PMAyush Paudel
04/27/2023, 12:49 PMimport lakefs_client
from lakefs_client.api import objects_api
from pprint import pprint
import os
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure HTTP basic authorization: basic_auth
configuration = lakefs_client.Configuration(
username="AKIAJNGGC7PVSVQG7G3Q",
password="3NUzNiTiJdGtCP1urPyLztoW/XHy7yPBhzHFK48L",
host="<http://localhost:8000/api/v1>",
)
# Enter a context with an instance of the API client
with lakefs_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = objects_api.ObjectsApi(api_client)
repository = "example-repo" # str |
ref = "main" # str | destination branch for the copy
path = "test.py" # str | destination path relative to the branch
# example passing only required values which don't have defaults set
try:
os.chdir("/Users/ayushpaudel/codebase/lakefs-poc/")
# create a copy of an object
api_response = api_instance.get_object(repository, ref, path)
pprint(api_response)
except lakefs_client.ApiException as e:
print("Exception when calling ObjectsApi->copy_object: %s\n" % e)
and this is the output
-> python3 lakefs-sdk.py
<_io.BufferedReader name='/var/folders/jk/jv05v3l53pl4kx83db_wmr840000gn/T/tmpl2ohp9m7'>
Barak Amar
04/27/2023, 1:35 PMfile_type
from get_object
is io.BufferedReader
as it say in the output. You will need to read the content to your desired location.with client.objects.get_object("repository", "branch", "README.md") as r, \
open('README.md', 'wb') as w:
w.write(r.read())
Ayush Paudel
04/27/2023, 2:01 PMlakectl fs download
where we do specify download path. thats whyBarak Amar
04/27/2023, 2:08 PM