> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/aistore/llms.txt.

# aistore.sdk.etl.webserver.utils

## Module Contents

### Classes

| Name                                                                        | Description                                                              |
| --------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| [`_ResponseRawReader`](#aistore-sdk-etl-webserver-utils-_ResponseRawReader) | Wrap a requests.Response so close() releases the connection to the pool. |

### Functions

| Name                                                                                        | Description                                                                   |
| ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [`compose_etl_direct_put_url`](#aistore-sdk-etl-webserver-utils-compose_etl_direct_put_url) | Compose the final direct PUT URL by combining components from multiple URLs.  |
| [`parse_etl_pipeline`](#aistore-sdk-etl-webserver-utils-parse_etl_pipeline)                 | Parse ETL pipeline from header value with validation.                         |
| [`serialize_class`](#aistore-sdk-etl-webserver-utils-serialize_class)                       | Pickle and base64-encode a user-provided ETLServer subclass for transmission. |

### API

```python
class aistore.sdk.etl.webserver.utils._ResponseRawReader(
    response: requests.Response
)
```

Wrap a requests.Response so close() releases the connection to the pool.

resp.raw\.close() closes the socket but skips resp.close()'s release_conn()
call, which returns the socket to the keep-alive pool. Under early-close
(mid-stream errors, client disconnects), that leaks connections.
All reads are delegated to resp.raw; everything else falls through to resp.raw.

**`_raw`** `= response.raw`

---

```python
aistore.sdk.etl.webserver.utils._ResponseRawReader.__getattr__(
    name
)
```

```python
aistore.sdk.etl.webserver.utils._ResponseRawReader.close()
```

Close the response so requests releases the connection to the pool.

```python
aistore.sdk.etl.webserver.utils._ResponseRawReader.read(
    args = (),
    kwargs = {}
)
```

Read bytes from the underlying raw response stream.

```python
aistore.sdk.etl.webserver.utils.compose_etl_direct_put_url(
    direct_put_url: str,
    host_target: str,
    obj_path: str,
    etl_args: str = ''
) -> str
```

Compose the final direct PUT URL by combining components from multiple URLs.

Scenarios:

1. Pipeline stage: direct_put_url has no path → append object path.
2. Offline transform: direct_put_url has a path → prepend host_target path
   (e.g. "/v1/etl/\_object/\<etl-name>/\<etl-secret>/") to validate request.

Returns:
str: Complete direct PUT URL targeting the correct AIS node.

**Parameters:**

**`direct_put_url`** `str`

Destination node's direct PUT URL, possibly with path/query.

---

**`host_target`** `str`

Base AIS target URL used for scheme and base path.

---

**`obj_path`** `str`

Decoded path of the object to PUT.

---

**`etl_args`** `str` — default: ''

Per-request transform arguments to forward to the next
pipeline stage (the receiving ETL server reads them from the incoming
query). Empty string forwards nothing.

---

```python
aistore.sdk.etl.webserver.utils.parse_etl_pipeline(
    pipeline_header: str
) -> typing.Tuple[str, str]
```

Parse ETL pipeline from header value with validation.

**Parameters:**

**`pipeline_header`** `str`

Comma-separated pipeline URLs

---

**Returns:** `str`

Tuple of (first_url, remaining_pipeline_header)

**Raises:**

* `InvalidPipelineError`: If pipeline header is malformed

```python
aistore.sdk.etl.webserver.serialize_class(
    cls: typing.Type[aistore.sdk.etl.webserver.base_etl_server.ETLServer],
    encoding: str = UTF_ENCODING
) -> str
```

Pickle and base64-encode a user-provided ETLServer subclass for transmission.

**Parameters:**

**`cls`** `Type[ETLServer]`

`Type[` [`ETLServer`](/aistore/api-reference/python/aistore/sdk/etl/webserver/base_etl_server#aistore-sdk-etl-webserver-base_etl_server-ETLServer) `]` — A subclass of ETLServer to serialize.

---

**`encoding`** `str` — default: UTF_ENCODING

The string encoding for the Base64 payload.

---

**Returns:** `str`

A Base64 string containing the pickled class.

**Raises:**

* `TypeError`: If `cls` is not a subclass of ETLServer.