MCPcopy
hub / github.com/kserve/kserve / explain_response

Function explain_response

test/e2e/common/utils.py:208–250  ·  view source on GitHub ↗
(
    client, service_name, input_path, network_layer: str
)

Source from the content-addressed store, hash-verified

206
207
208async def explain_response(
209 client, service_name, input_path, network_layer: str
210) -> Dict:
211 kfs_client = KServeClient(
212 config_file=os.environ.get("KUBECONFIG", "~/.kube/config")
213 )
214 isvc = kfs_client.get(
215 service_name,
216 namespace=KSERVE_TEST_NAMESPACE,
217 version=constants.KSERVE_V1BETA1_VERSION,
218 )
219 scheme, cluster_ip, host, path = get_isvc_endpoint(isvc, network_layer)
220 url = f"{scheme}://{cluster_ip}{path}"
221 headers = {"Host": host}
222 with open(input_path) as json_file:
223 data = json.load(json_file)
224 logger.info("Sending request data: %s", data)
225 try:
226 response = await client.explain(
227 url, model_name=service_name, data=data, headers=headers
228 )
229 except (RuntimeError, orjson.JSONDecodeError) as e:
230 logger.info("Explain error -------")
231 pods = kfs_client.core_api.list_namespaced_pod(
232 KSERVE_TEST_NAMESPACE,
233 label_selector="serving.kserve.io/inferenceservice={}".format(
234 service_name
235 ),
236 )
237 for pod in pods.items:
238 logger.info(pod)
239 logger.info(
240 "%s\t%s\t%s"
241 % (pod.metadata.name, pod.status.phase, pod.status.pod_ip)
242 )
243 api_response = kfs_client.core_api.read_namespaced_pod_log(
244 pod.metadata.name,
245 KSERVE_TEST_NAMESPACE,
246 container="kserve-container",
247 )
248 logger.info(api_response)
249 raise e
250 return response
251
252
253def get_cluster_ip(namespace="istio-system", labels: dict = None):

Callers 1

explain_artFunction · 0.85

Calls 6

getMethod · 0.95
KServeClientClass · 0.90
get_isvc_endpointFunction · 0.85
infoMethod · 0.80
loadMethod · 0.45
explainMethod · 0.45

Tested by

no test coverage detected