---
sidebar:
  label: roboto.storage.download_session
  order: 3
title: roboto.storage.download_session
---
## Module Contents

### DownloadSession

```python
class roboto.storage.download_session.DownloadSession(
    items: collections.abc.Sequence[DownloadableFile],
    association: roboto.association.Association,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
    caller_org_id: Optional[str] = None,
)
```

`from roboto.storage.download_session import DownloadSession`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/download_session.py#L45-L170)

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**

```python
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]`)
- **association** (`roboto.association.Association`)
- **roboto_client** (`Optional[roboto.http.RobotoClient]`)
- **caller_org_id** (`Optional[str]`)

#### DownloadSession.await_downloads()

```python
def await_downloads() -> list[tuple[DownloadableFile, Exception]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/download_session.py#L138-L162)

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()

```python
def make_credential_provider(
    bucket_name: Optional[str] = None,
) -> roboto.storage.object_store.CredentialProvider
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/download_session.py#L110-L136)

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

**Parameters**

- **bucket_name** (`Optional[str]`)

**Returns**

- `roboto.storage.object_store.CredentialProvider`

#### DownloadSession.register_download()

```python
def register_download(
    file: DownloadableFile,
    future: roboto.storage.object_store.FutureLike[None],
) -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/download_session.py#L164-L170)

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** (`DownloadableFile`)
- **future** (`roboto.storage.object_store.FutureLike[None]`)

**Returns**

- `None`

### DownloadableFile

```python
class roboto.storage.download_session.DownloadableFile
```

`from roboto.storage import DownloadableFile`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/download_session.py#L32-L42)

Bases: `TypedDict`

A file to be downloaded from the Roboto Platform.

**Attributes**

- **DownloadableFile.bucket_name** (`str`): Name of the bucket where the file is stored.
- **DownloadableFile.destination_path** (`pathlib.Path`): Local path where the file should be saved.
- **DownloadableFile.source_uri** (`str`): Full URI of the file in cloud storage (e.g., 's3://bucket/key').

### logger

```python
roboto.storage.download_session.logger
```

`from roboto.storage.download_session import logger`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/storage/download_session.py#L29-L29)
