roboto.storage
Remote file storage I/O.
Whole-file transfer (upload transactions, download sessions, credentials, and the object-store abstraction) for moving files in and out of Roboto storage, plus the range-reader, local cache, and sparse-buffer primitives for streaming byte-range reads that the format decoders in roboto.formats build on.
Submodules
Package Contents
AbortTransactionsRequest
Bases: pydantic.BaseModel
Request payload for aborting file upload transactions.
Used to cancel ongoing file upload transactions, typically when uploads fail or are no longer needed. This cleans up any reserved resources and marks associated files as no longer pending.
Parameters
data AnyAttributes
AbortTransactionsRequest.transaction_ids
List of transaction IDs to abort.
BeginSignedUrlUploadRequest
Bases: pydantic.BaseModel
Request payload to begin a single file upload with a signed URL.
Used for simpler upload scenarios where a pre-signed URL is preferred over temporary credentials. The returned URL can be used directly for uploading the file content.
Parameters
data AnyAttributes
BeginSignedUrlUploadRequest.association
The entity this file will be associated with (e.g., dataset, topic).
BeginSignedUrlUploadRequest.file_path
Destination path for the file within the association.
BeginSignedUrlUploadRequest.origination
Optional description of the upload source.
BeginSignedUrlUploadResponse
Bases: pydantic.BaseModel
Response from beginning a single file upload.
Contains the upload ID for completing the transaction and a pre-signed URL that can be used to upload the file content directly.
Parameters
data AnyBeginUploadRequest
Bases: pydantic.BaseModel
Request payload to begin a batch file upload transaction.
Used to initiate a multi-file upload transaction for any association type (dataset, topic, etc.). Returns a transaction ID and upload mappings that specify where each file should be uploaded.
Parameters
data AnyAttributes
BeginUploadRequest.association
The entity these files will be associated with (e.g., dataset, topic).
BeginUploadRequest.device_id
Optional identifier of the device that generated this data.
BeginUploadRequest.origination
Description of the upload source (e.g., ‘roboto-sdk v1.0.0’).
BeginUploadRequest.resource_manifest
Dictionary mapping destination file paths to file sizes in bytes.
BeginUploadResponse
Bases: pydantic.BaseModel
Response from beginning a batch upload transaction.
Contains the transaction ID needed for subsequent progress reporting and completion calls, plus mappings from file paths to their upload URIs.
Parameters
data AnyCachePolicy
Bases: str, enum.Enum
Governs whether a fetched data file is cached to local disk before reading.
The policy applies to formats with a disk-cache path (Parquet today); a format that always streams (MCAP) ignores it.
Attributes
CachePolicy.ADAPTIVE
Reuse an already-cached file; otherwise download when the read projects enough columns (COLUMN_COUNT_LOCAL_CACHE_THRESHOLD) to justify it, and stream over HTTP when it does not.
CachePolicy.ALWAYS
Download the file to the local cache before reading, regardless of how much of it the read projects.
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’).
FileService
Application service for performing upload and download to the Roboto Platform.
Agnostic to object store provider.
Parameters
roboto_client Optional[roboto.object_store_registry Optional[roboto.FileService.download()
Download files from the Roboto Platform.
Parameters
files collections.Sequence of files to download, each with source_uri and destination_path.
association roboto.Association of the files to download.
caller_org_id Optional[str]Optional organization ID for cross-org access.
on_progress Optional[roboto.Optional callback to be periodically called with the number of bytes downloaded.
Return type
FileService.upload()
Upload the given files and return which file record each one created.
Parameters
files collections.association roboto.destination_paths collections.batch_size intdevice_id Optional[str]caller_org_id Optional[str]on_progress Optional[roboto.Returns
Mapping from each uploaded local path to the ID of the file record it created.
Raises
ValueErrorIf two of the given files resolve to the same destination path: their uploads would overwrite each other and only one could appear in the returned mapping. Files without a destination_paths entry are destined for their own basename, so two like-named files from different directories collide unless given distinct destinations.
OSErrorIf a given file cannot be read.
HttpRangeReader
A seekable, buffered byte-range reader backed by an HTTP URL.
Uses HTTP range requests so only the requested byte ranges are fetched, allowing efficient partial access to remote files (e.g., reading just the MCAP summary/index section at the end of a file without downloading the full data payload).
Reads are satisfied from an in-memory sparse cache. HTTP requests are only issued on a cache miss, fetching READ_AHEAD_SIZE bytes at a time. Unlike a simple single-buffer approach, this cache retains all fetched regions, so seeking back to previously-read data doesn’t trigger re-fetches.
This class implements the IO[bytes] protocol methods needed by mcap.reader.
Uses urllib3 connection pooling to reuse HTTP connections across requests, reducing TCP handshake and TLS negotiation overhead.
Parameters
url strread_ahead_size intHttpRangeReader.close()
Close the reader and release resources.
Return type
HttpRangeReader.prefetch_range()
Prefetch a byte range using parallel HTTP requests.
Byte spans already in the cache (e.g., placed there by the footer read-behind at open, which covers the whole file when it is small) are not re-fetched; only the uncovered gaps are requested.
Parameters
start intStart byte offset (inclusive)
end intEnd byte offset (inclusive)
Return type
HttpRangeReader.read()
Parameters
size intReturn type
HttpRangeReader.readable()
Return type
HttpRangeReader.seek()
Parameters
offset intwhence intReturn type
HttpRangeReader.seekable()
Return type
Properties
HttpRangeReader.tell()
Return type
HttpRangeReader.writable()
Return type
ReportUploadProgressRequest
Bases: pydantic.BaseModel
Request payload for reporting file upload progress.
Used to notify the platform about the completion status of individual files within a batch upload transaction. This enables progress tracking and partial completion handling for large file uploads.
Parameters
data AnyAttributes
ReportUploadProgressRequest.manifest_items
List of file URIs that have completed upload.
ReportUploadProgressResponseItem
Bases: pydantic.BaseModel
One file marked available by a progress report.
The service returns one item per reported URI that matched a file of the transaction, and omits URIs that matched none; the omission does not fail the request on the server side. UploadTransaction is stricter with the response it receives: every URI it reports comes from the transaction’s own upload mappings, so a missing pair means client and service disagree about the transaction’s contents, and it raises RobotoInternalException.
Parameters
data AnyRobotoCredentials
Bases: pydantic.BaseModel
Credentials returned from the Roboto Platform
Parameters
data AnyRobotoCredentials.is_expired()
Return type
RobotoCredentials.to_dict()
Return type
RobotoCredentials.to_object_store_credentials()
Return type
SparseBuffer
A seekable, read-only file-like object backed by sparse in-memory byte regions.
Stores fetched byte regions and provides a standard IO[bytes] interface for reading from them. Regions are automatically merged when they overlap or are adjacent, keeping the internal representation compact.
This is intended to be used as: 1. The cache backend for HttpRangeReader (sparse storage with smart fetching) 2. The stream for mcap.reader.SeekingReader after bulk-fetching byte ranges
Usage
buf = SparseBuffer(file_size=1000)
buf.add_region(0, b"MCAP_MAGIC") # header
buf.add_region(900, b"footer_data") # footer
buf.seek(0)
# 0
buf.read(10)
# b'MCAP_MAGIC'Parameters
file_size intSparseBuffer.add_region()
Store a byte region at the given file offset.
Merges with any overlapping or adjacent existing regions.
Parameters
offset intByte offset within the virtual file.
data bytesRaw bytes to store at that offset.
Return type
SparseBuffer.clear()
Remove all cached regions.
Return type
SparseBuffer.find_region()
Check if [start, start+size) is fully contained in a cached region.
Parameters
start intStart byte offset.
size intNumber of bytes.
Returns
The requested bytes if fully cached, None otherwise.
SparseBuffer.read()
Read up to size bytes from the current position.
If the current position is within a cached region, returns available bytes (may be fewer than requested if the region ends before size bytes). If the current position is not in any cached region (a gap), returns b”“.
This allows callers to detect partial hits and fetch missing data: - len(result) == size: fully satisfied - 0 < len(result) < size: partial hit, more data may be needed - len(result) == 0: gap at current position, caller should fetch
Parameters
size intMaximum number of bytes to read. -1 means read to end of file.
Returns
Bytes read from cached regions, or b”” if at a gap or past EOF.
SparseBuffer.readable()
Return True - this buffer supports reading.
Return type
Properties
SparseBuffer.regions
List of (start, end) byte ranges currently cached.
End is exclusive. Useful for fetch planning and debugging.
SparseBuffer.seek()
Move the read position.
Parameters
offset intByte offset relative to the position indicated by whence.
whence int0=SEEK_SET (start), 1=SEEK_CUR (current), 2=SEEK_END (end).
Returns
The new absolute position.
SparseBuffer.seekable()
Return True - this buffer supports seeking.
Return type
Properties
SparseBuffer.tell()
Return the current read position.
Return type
SparseBuffer.writable()
Return False - this buffer is read-only.
Return type
as_io_bytes()
Cast an HttpRangeReader to typing.IO[bytes] for type-checking purposes.
Parameters
reader HttpRangeReaderReturn type