aistore.sdk.etl.webserver.fastapi_server
aistore.sdk.etl.webserver.fastapi_server
Module Contents
Classes
Data
API
Bases: ETLServer
FastAPI server implementation for ETL transformations.
Construct standardized response with appropriate headers.
Sends the transformed object directly to the specified AIS node (direct_put_url),
eliminating the additional network hop through the original target.
Used only in bucket-to-bucket offline transforms.
Returns: status code, transformed data, length of the transformed data (if any) Raises: ETLDirectPutTransientError: on ReadError/ConnectError/RemoteProtocolError so the caller can retry without re-fetching data.
Parameters:
The first URL in the ETL pipeline
The transformed data to send
Comma-separated remaining pipeline stages to pass as header
The path of the object.
Stream transformed output directly to the next pipeline stage.
Returns: Tuple[int, bytes, int]
(status_code, body, length) where:
- status_code: HTTP status of the PUT (200/204 on success, 500 on error).
- body: response bytes forwarded back to the AIS target (empty on success).
- length: bytes sent to the destination, from CountingIterator.
Stream-put with exponential-backoff retry on transient network errors.
Each retry reopens the source and rebuilds the transform generator
from scratch. Sources that can be reopened: FQN-backed (re-open the
file) or GET (re-issue the upstream stream). Streaming no-FQN PUT is
not replayable — request.stream() is one-shot — so retries are
skipped for that case and AIS retries the whole PUT instead.
Parameters:
Local FQN of the source object on the target’s
filesystem. Empty string when the body comes from
request.stream().
Object path (e.g. "bucket/object-name") forwarded
to the next pipeline stage and passed to transform_stream.
Incoming Request; its body is the source
when fqn is empty and is_get is False.
True for hpull GET, False for hpush PUT.
Per-request transformation arguments (may be empty).
First URL in the direct-put pipeline (next stage).
Comma-separated remaining pipeline stages,
forwarded to the next stage via the AIS-Node-Url header.
Returns: Tuple[int, bytes, int]
Tuple[int, bytes, int]: (status_code, body, length) — see
_direct_put_stream for semantics.
Raises:
ETLDirectPutTransientError: if all retry attempts are exhausted.
Buffered direct-put with exponential-backoff retry on transient network errors.
Raises: ETLDirectPutTransientError: if all retry attempts are exhausted.
Returns: Tuple[int, bytes, int]
(status_code, body, length) — see _direct_put for semantics.
Safely read local file content with path normalization.
Retrieve content from AIS target with async HTTP client.
Get a BinaryIO reader for the request source data.
Unified request handler for GET/PUT operations.
Buffered request handler — loads entire object, transforms, returns.
Streaming request handler — yields output chunks without buffering.
Handle a single WebSocket message. Always uses buffered transform().
Yield data in chunk_size pieces as an async bytes generator.
Recommended approach for large PUT bodies with httpx.AsyncClient.
See https://www.python-httpx.org/async/#streaming-requests.
Open a streaming GET against the AIS target using the shared sync session.
Blocking — must be called via asyncio.to_thread from an async context. Returns a _ResponseRawReader wrapping the response so close() releases the connection back to the urllib3 keep-alive pool.
Configure FastAPI routes and event handlers.
Cleanup resources on server shutdown.
Start the server with production-optimized settings.
Initialize resources on server startup.