Client¶
Uploading¶
sender
¶
BatchProgressCallback
¶
Bases: Protocol
Callback protocol for observing batch upload progress.
async_send_file
async
¶
async_send_file(
source: Path | MZMLFile | MSZFile | MSZXFile,
base_url: str,
progress_callback: Callable[[int], None] | None = None,
timeout: Timeout | None = None,
poll_timeout: float | None = 3600.0,
chunk_size: int = 1048576,
api_key: str | None = None,
client: AsyncClient | None = None,
) -> UploadResponse
Send a single file to the mstransfer listener (async).
Accepts a file path, or an already-opened MZMLFile / MSZFile / MSZXFile from mscompress. Returns the final transfer status from the server.
timeout replaces client's timeouts for the upload request; pass
httpx.Timeout(None) for no limit. If None, client's timeouts
are used (10 s connect, 3600 s otherwise, without client).
poll_timeout is how long to wait without server-side progress while polling for completion, in seconds, or None to wait forever. Status polls use client's timeout, or 10 s without client.
async_send_batch
async
¶
async_send_batch(
sources: Sequence[Path | MZMLFile | MSZFile | MSZXFile],
base_url: str,
parallel: int = 4,
chunk_size: int = 1048576,
progress: BatchProgressCallback | None = None,
api_key: str | None = None,
client: AsyncClient | None = None,
timeout: Timeout | None = None,
poll_timeout: float | None = 3600.0,
) -> list[FileResult[UploadResponse]]
Send multiple files with configurable parallelism (async).
Returns one FileResult per source, in input order, carrying
the final transfer status or the error.
timeout and poll_timeout are passed to async_send_file for
each file.
send_file
¶
send_file(
source: Path | MZMLFile | MSZFile | MSZXFile,
base_url: str,
progress_callback: Callable[[int], None] | None = None,
timeout: Timeout | None = None,
poll_timeout: float | None = 3600.0,
chunk_size: int = 1048576,
api_key: str | None = None,
client: AsyncClient | None = None,
) -> UploadResponse
Send a single file to the mstransfer listener.
Accepts a file path, or an already-opened MZMLFile / MSZFile / MSZXFile from mscompress. Returns the final transfer status from the server.
This is a synchronous wrapper around async_send_file.
send_batch
¶
send_batch(
sources: Sequence[Path | MZMLFile | MSZFile | MSZXFile],
base_url: str,
parallel: int = 4,
chunk_size: int = 1048576,
progress: BatchProgressCallback | None = None,
api_key: str | None = None,
client: AsyncClient | None = None,
timeout: Timeout | None = None,
poll_timeout: float | None = 3600.0,
) -> list[FileResult[UploadResponse]]
Send multiple files with configurable parallelism.
timeout and poll_timeout are passed to async_send_file for each
file.
This is a synchronous wrapper around async_send_batch.
Downloading¶
downloader
¶
DownloadProgressCallback
¶
Bases: Protocol
Callback protocol for observing single-file download progress.
BatchDownloadProgress
¶
Bases: Protocol
Callback protocol for observing batch download progress.
DownloadRequest
dataclass
¶
A single download request: URL to fetch and local destination path.
DownloadResult
dataclass
¶
DownloadResult(
request: DownloadRequest,
path: Path,
skipped: bool = False,
)
A completed download: the request and where its output was written.
skipped is True when the output already existed and nothing was downloaded (see skip_existing).
async_download_file
async
¶
async_download_file(
url: str,
dest: Path,
*,
store_as: DownloadFormat | None = None,
chunk_size: int = 1048576,
timeout: Timeout | None = None,
progress_callback: DownloadProgressCallback
| None = None,
skip_existing: bool = False,
force: bool = False,
resume: bool = True,
api_key: str | None = None,
client: AsyncClient | None = None,
) -> Path
Download a single file from url to dest (async).
The file is streamed to a temporary .part file first, then atomically
renamed (or converted) to the final destination on success.
With resume, an interrupted download keeps its partial .part file
(and a .part.json describing it) next to dest, and a later call
continues from the bytes already received. A partial is only kept when
the server sent a strong ETag and the body size, and it is only
resumed with an If-Range request carrying that ETag. If the
server does not support ranges, or the file changed, the download
restarts from zero. The finished file must have exactly the expected
size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to download from. |
required |
dest
|
Path
|
The local path where the file should be saved. If store_as requires a format conversion, the extension will be adjusted automatically. |
required |
store_as
|
DownloadFormat | None
|
Desired output format — |
None
|
chunk_size
|
int
|
Number of bytes per read chunk (default 1 MiB). |
1048576
|
timeout
|
Timeout | None
|
Timeouts for the request, replacing client's; pass
|
None
|
progress_callback
|
DownloadProgressCallback | None
|
Optional callback. |
None
|
skip_existing
|
bool
|
If True and the final destination already exists,
skip the download. For an |
False
|
force
|
bool
|
If True, re-download even if the destination already exists (overrides skip_existing), discarding any partial download. |
False
|
resume
|
bool
|
If True (the default), resume a partial download of url
to dest and keep this one's partial if it is interrupted. Only
one download to dest at a time can do so; a concurrent one uses
a private |
True
|
api_key
|
str | None
|
Optional API key, sent as |
None
|
client
|
AsyncClient | None
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The final destination path (may differ from dest if the extension |
Path
|
was adjusted for format conversion), or the archive directory for a |
Path
|
multi-member |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
The source cannot be converted to store_as. |
ValueError
|
Two members of a multi-member |
async_download_batch
async
¶
async_download_batch(
files: list[DownloadRequest],
*,
store_as: DownloadFormat | None = None,
parallel: int = 4,
chunk_size: int = 1048576,
timeout: Timeout | None = None,
progress: BatchDownloadProgress | None = None,
skip_existing: bool = False,
force: bool = False,
resume: bool = True,
api_key: str | None = None,
client: AsyncClient | None = None,
) -> list[FileResult[DownloadResult]]
Download multiple files in parallel (async).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list[DownloadRequest]
|
List of |
required |
store_as
|
DownloadFormat | None
|
Desired output format — |
None
|
parallel
|
int
|
Maximum number of concurrent downloads (capped to file count). |
4
|
chunk_size
|
int
|
Number of bytes per read chunk. |
1048576
|
timeout
|
Timeout | None
|
Timeouts for each request, replacing client's; pass
|
None
|
progress
|
BatchDownloadProgress | None
|
Optional batch progress callback. |
None
|
skip_existing
|
bool
|
If True, skip files whose destination already exists. |
False
|
force
|
bool
|
If True, re-download even if destination exists. |
False
|
resume
|
bool
|
If True (the default), resume partial downloads and keep
resumable partials of failed ones (see |
True
|
api_key
|
str | None
|
Optional API key, sent as |
None
|
client
|
AsyncClient | None
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
list[FileResult[DownloadResult]]
|
One result per request, in input order, named after the request's |
list[FileResult[DownloadResult]]
|
dest, carrying either a |
list[FileResult[DownloadResult]]
|
multi-member |
list[FileResult[DownloadResult]]
|
file skipped by skip_existing has |
list[FileResult[DownloadResult]]
|
reported to progress as complete. |
download_file
¶
download_file(
url: str,
dest: Path,
*,
store_as: DownloadFormat | None = None,
chunk_size: int = 1048576,
timeout: Timeout | None = None,
progress_callback: DownloadProgressCallback
| None = None,
skip_existing: bool = False,
force: bool = False,
resume: bool = True,
api_key: str | None = None,
client: AsyncClient | None = None,
) -> Path
Download a single file from url to dest.
This is a synchronous wrapper around async_download_file.
download_batch
¶
download_batch(
files: list[DownloadRequest],
*,
store_as: DownloadFormat | None = None,
parallel: int = 4,
chunk_size: int = 1048576,
timeout: Timeout | None = None,
progress: BatchDownloadProgress | None = None,
skip_existing: bool = False,
force: bool = False,
resume: bool = True,
api_key: str | None = None,
client: AsyncClient | None = None,
) -> list[FileResult[DownloadResult]]
Download multiple files in parallel.
This is a synchronous wrapper around async_download_batch.
Results¶
results
¶
FileResult
dataclass
¶
Bases: Generic[T]
Result of transferring a single file in a batch.
Uploads return FileResult[UploadResponse] and downloads return
FileResult[DownloadResult], one per input, in input order.
Exactly one of response and error is set: response on success, error the exception that failed the transfer. An exception raised by the batch's completion progress callback is logged and does not count as a failure.
Utilities¶
resolve_inputs
¶
Resolve files and directories into a sorted list of valid MS files.