roboto.storage.download_session
Module Contents
DownloadSession
Manages a batch of file downloads with shared credentials.
Provides credential lifecycle management and async operation coordination for downloading the files of one association: a dataset, a device, or an org. Unlike UploadTransaction, this does not manage an API transaction since downloads don’t require server-side state tracking.
Usage
session = DownloadSession(
items=[
{"bucket_name": "bucket", "source_uri": "s3://bucket/key", "destination_path": Path("/tmp/file")}
],
association=Association.dataset("ds_123"),
)
object_store = registry.get_store_for_uri(uri, session.credential_provider)
with object_store:
for file in session:
future = object_store.get(file["source_uri"], file["destination_path"])
session.register_download(file, future)Parameters
items collections.association roboto.roboto_client Optional[roboto.caller_org_id Optional[str]DownloadSession.await_downloads()
Wait for all registered downloads to complete.
Must be called while still inside the object_store context manager, since the transfer manager may be shut down when that context exits.
Returns
List of (file, exception) tuples for downloads that failed. Empty list if all downloads succeeded.
DownloadSession.make_credential_provider()
Return a credential provider for read-only access to the association’s files.
Parameters
bucket_name Optional[str]DownloadSession.register_download()
Register a pending download future.
Call this immediately after initiating each download transfer. The future will be awaited when await_downloads() is called.
Parameters
file DownloadableFilefuture roboto.Return type
DownloadableFile
Bases: TypedDict
A file to be downloaded from the Roboto Platform.
Attributes
DownloadableFile.destination_path
Local path where the file should be saved.
DownloadableFile.source_uri
Full URI of the file in cloud storage (e.g., ‘s3://bucket/key’).