Skip to content
Roboto
Esc
↑↓navigate↵open⌘Jpreview
On this page

roboto.storage.download_session

Module Contents

DownloadSession

class roboto.storage.download_session.DownloadSession(items, association, roboto_client=None, caller_org_id=None)#View Source

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.abc.Sequence[DownloadableFile]
roboto_client Optional[roboto.http.RobotoClient]
caller_org_id Optional[str]

DownloadSession.await_downloads()

await_downloads()#View Source

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[tuple[DownloadableFile, Exception]]

List of (file, exception) tuples for downloads that failed. Empty list if all downloads succeeded.

DownloadSession.make_credential_provider()

make_credential_provider(bucket_name=None)#View Source

Return a credential provider for read-only access to the association’s files.

Parameters

bucket_name Optional[str]

DownloadSession.register_download()

register_download(file, future)#View Source

Register a pending download future.

Call this immediately after initiating each download transfer. The future will be awaited when await_downloads() is called.

Return type

None

DownloadableFile

class roboto.storage.download_session.DownloadableFile#View Source

Bases: TypedDict

A file to be downloaded from the Roboto Platform.

Attributes

DownloadableFile.bucket_name

bucket_name str #

Name of the bucket where the file is stored.

DownloadableFile.destination_path

destination_path pathlib.Path #

Local path where the file should be saved.

DownloadableFile.source_uri

source_uri str #

Full URI of the file in cloud storage (e.g., ‘s3://bucket/key’).

logger

roboto.storage.download_session.logger#View Source

Was this page helpful?