ts.torch_handler.request_envelope 套件¶
子模組¶
ts.torch_handler.request_envelope.base 模組¶
所有 RequestEnvelope 的基底類別。
請求信封會重新格式化呼叫處理器的輸入/輸出。 它將特定於模型協調器(如 Seldon 或 KServe)的格式轉換為一組扁平的 Python 項目,反之亦然。
ts.torch_handler.request_envelope.body 模組¶
所有處理器的預設類別。 從請求內文中抓取資料。
ts.torch_handler.request_envelope.json 模組¶
使用 JSON 格式化的輸入/輸出,遵循 https://tensorflow.dev.org.tw/tfx/serving/api_rest 中概述的結構
ts.torch_handler.request_envelope.kserve 模組¶
KServe Envelope 用於處理 Torchserve 內部的 KServe 輸入請求。
- class ts.torch_handler.request_envelope.kserve.KServeEnvelope(handle_fn)[原始碼]¶
基底:
BaseEnvelope
此函數用於處理 Kserve 格式中指定的輸入請求,並將其轉換為 Torchserve 可讀取的格式。
- 參數:
Format (data - Kserve 中的輸入請求清單) –
- 傳回:
傳回 Torchserve 格式的輸入請求清單
- 傳回類型:
[list]
ts.torch_handler.request_envelope.kservev2 模組¶
KServe Envelope 用於處理 Torchserve 內部的 KServe 輸入請求。
- class ts.torch_handler.request_envelope.kservev2.KServev2Envelope(handle_fn)[原始碼]¶
基底:
BaseEnvelope
實作。以 KServe v2 協議格式捕獲批次,也以 FServing v2 協議格式傳回。
- format_output(data)[原始碼]¶
將 Torchserve 輸出轉換為 KServe v2 回應格式。
參數: data (清單): 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]
}]
}
- parse_input(data)[原始碼]¶
將 KServe 請求輸入轉換為 Torchserve 預期的資料清單。
參數: data (json): KServe v2 請求輸入 json。{
- “inputs”: [{
“name”: “input-0”, “shape”: [37], “datatype”: “INT64”, “data”: [66, 108, 111, 111, 109]
}]
}
傳回: 資料物件清單。[{ ‘name’: ‘input-0’, ‘shape’: [5], ‘datatype’: ‘INT64’, ‘data’: [66, 108, 111, 111, 109] }]