Arena utilities¶
Upload helpers shared by ArenaClient.
- agilerl.arena.utils.extract_filename(disposition: str | None) str | None¶
Parse a filename from a Content-Disposition header value.
- agilerl.arena.utils.prepare_env_upload(source: str | PathLike[str] | bytes) tuple[str, BinaryIO | bytes]¶
Resolve an environment source into an upload-ready
(name, payload)pair.source may be:
A path to a directory — compressed into
.tar.gzautomatically.A path to a single file — compressed into
.tar.gzautomatically.A path to an existing
.tar.gzfile — opened for streaming as-is.Raw
bytes— used directly (assumed to be a valid.tar.gz).
Path inputs resolve to open binary handles so httpx streams the upload in chunks instead of holding the whole artifact in memory; the caller is responsible for closing them once the request has been sent.
- agilerl.arena.utils.prepare_file_upload(source: str | PathLike[str] | bytes, *, default_name: str, content_type: str, filename: str | None = None) tuple[str, BinaryIO | bytes, str]¶
Resolve a path or raw bytes into an httpx multipart file tuple.
Path inputs resolve to open binary handles so httpx streams the upload in chunks instead of reading the whole file into memory; the caller is responsible for closing them once the request has been sent.
- Parameters:
- Returns:
(filename, payload, content_type)for httpxfiles=.- Return type:
- Raises:
ArenaFileNotFoundError – If source is a path that does not exist.