MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / _upsert_managed_inference

Function _upsert_managed_inference

e2e/python/test_inference_routing.py:57–105  ·  view source on GitHub ↗
(
    inference_client: InferenceRouteClient,
    sandbox_client: SandboxClient,
    *,
    provider_name: str,
    provider_type: str,
    credential_key: str,
    base_url_key: str,
    model_id: str,
    base_url: str,
)

Source from the content-addressed store, hash-verified

55
56
57def _upsert_managed_inference(
58 inference_client: InferenceRouteClient,
59 sandbox_client: SandboxClient,
60 *,
61 provider_name: str,
62 provider_type: str,
63 credential_key: str,
64 base_url_key: str,
65 model_id: str,
66 base_url: str,
67) -> None:
68 provider = datamodel_pb2.Provider(
69 metadata=datamodel_pb2.ObjectMeta(name=provider_name),
70 type=provider_type,
71 credentials={credential_key: "mock"},
72 config={
73 base_url_key: base_url,
74 },
75 )
76 timeout = sandbox_client._timeout
77
78 for _ in range(5):
79 try:
80 sandbox_client._stub.UpdateProvider(
81 openshell_pb2.UpdateProviderRequest(provider=provider),
82 timeout=timeout,
83 )
84 break
85 except grpc.RpcError as exc:
86 if exc.code() != grpc.StatusCode.NOT_FOUND:
87 raise
88
89 try:
90 sandbox_client._stub.CreateProvider(
91 openshell_pb2.CreateProviderRequest(provider=provider),
92 timeout=timeout,
93 )
94 break
95 except grpc.RpcError as create_exc:
96 if create_exc.code() == grpc.StatusCode.ALREADY_EXISTS:
97 continue
98 raise
99 else:
100 raise RuntimeError("failed to upsert managed e2e provider after retries")
101
102 inference_client.set_cluster(
103 provider_name=provider_name,
104 model_id=model_id,
105 )
106
107
108def _current_cluster_inference(

Callers 1

managed_openai_routeFunction · 0.85

Calls 2

codeMethod · 0.80
set_clusterMethod · 0.80

Tested by

no test coverage detected