ts.torch_handler.request_envelope 包¶
子模組¶
ts.torch_handler.request_envelope.base 模組¶
所有請求封裝的基類。
請求封裝會重新格式化呼叫處理器的輸入/輸出。它將 Seldon 或 KServe 等模型編排器特定的格式轉換為一組扁平的 Python 專案,反之亦然。
ts.torch_handler.request_envelope.body 模組¶
所有處理器的預設類。從請求體中獲取資料。
ts.torch_handler.request_envelope.json 模組¶
使用 JSON 格式的輸入/輸出,遵循 https://www.tensorflow.org/tfx/serving/api_rest 中概述的結構
ts.torch_handler.request_envelope.kserve 模組¶
KServe Envelope 用於處理 Torchserve 內的 KServe 輸入請求。
- class ts.torch_handler.request_envelope.kserve.KServeEnvelope(handle_fn)[source]¶
基類:
BaseEnvelope此函式用於處理以 kserve 格式指定的輸入請求,並將其轉換為 Torchserve 可讀格式。
- 引數:
格式 (data - 以 kserve 格式表示的輸入請求列表) –
- 返回:
返回 Torchserve 格式的輸入請求列表
- 返回型別:
[
list]
ts.torch_handler.request_envelope.kservev2 模組¶
KServe Envelope 用於處理 Torchserve 內的 KServe 輸入請求。
- class ts.torch_handler.request_envelope.kservev2.KServev2Envelope(handle_fn)[source]¶
基類:
BaseEnvelope實現。以 KServe v2 協議格式捕獲批次,也以 KServe v2 協議格式返回。
- format_output(data)[source]¶
將 Torchserve 輸出轉換為 KServe v2 響應格式。
引數: data (list): Torchserve 對處理器的響應。
返回: KServe v2 響應 json。{
“id”: “f0222600-353f-47df-8d9d-c96d96fa894e”, “model_name”: “bert”, “model_version”: “1”, “outputs”: [{
“name”: “input-0”, “shape”: [1], “datatype”: “INT64”, “data”: [2]
}]
}
- }]
將 KServe 請求輸入轉換為 Torchserve 所需的資料列表。
引數: data (json): KServe v2 請求輸入 json。{
- “inputs”: [{
“name”: “input-0”, “shape”: [37], “datatype”: “INT64”, “data”: [66, 108, 111, 111, 109]
}]
}
}] Returns: list of data objects. [{ ‘name’: ‘input-0’, ‘shape’: [5], ‘datatype’: ‘INT64’, ‘data’: [66, 108, 111, 111, 109] }]