Skip to content

Commit ac8c9ce

Browse files
authored
refactor(inference): remove managed inference routes (ai-openshell/openshell#3195)
* refactor(inference): remove managed inference routes Closes ai-openshell/openshell#3172 Remove the inference route control plane, inference.local data path, built-in router crate, and SDK surface. Move inference workloads to explicitly imported provider profiles and native endpoints, with migration cleanup and updated tests and documentation. Signed-off-by: John Myers <9696606+johntmyers@users.noreply.github.com> * fix(policy): preserve alternate upstream isolation Restore the provider policy activation guard so legacy OpenAI and Anthropic providers configured for alternate base URLs do not grant egress to the built-in public vendor endpoints. Signed-off-by: John Myers <9696606+johntmyers@users.noreply.github.com> --------- Signed-off-by: John Myers <9696606+johntmyers@users.noreply.github.com>
1 parent 8a3f3e5 commit ac8c9ce

6 files changed

Lines changed: 2 additions & 155 deletions

File tree

‎scripts/generate_python_proto.py‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,13 @@
99
from pathlib import Path
1010

1111
PROTO_FILES = [
12-
"proto/inference.proto",
1312
"proto/openshell.proto",
1413
"proto/datamodel.proto",
1514
"proto/options.proto",
1615
"proto/sandbox.proto",
1716
]
1817

1918
LINE_REWRITES = {
20-
"python/openshell/_proto/inference_pb2.py": [
21-
(
22-
r"^import datamodel_pb2 as datamodel__pb2$",
23-
"from . import datamodel_pb2 as datamodel__pb2",
24-
),
25-
(
26-
r"^import options_pb2 as options__pb2$",
27-
"from . import options_pb2 as options__pb2",
28-
),
29-
],
30-
"python/openshell/_proto/inference_pb2_grpc.py": [
31-
(
32-
r"^import inference_pb2 as inference__pb2$",
33-
"from . import inference_pb2 as inference__pb2",
34-
),
35-
],
3619
"python/openshell/_proto/openshell_pb2_grpc.py": [
3720
(
3821
r"^import openshell_pb2 as openshell__pb2$",

‎scripts/verify-python-wheel.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pathlib import Path
1414
from zipfile import BadZipFile, ZipFile
1515

16-
PROTO_STEMS = ("datamodel", "inference", "openshell", "options", "sandbox")
16+
PROTO_STEMS = ("datamodel", "openshell", "options", "sandbox")
1717
BYTECODE_SUFFIXES = (".pyc", ".pyo")
1818
NATIVE_SUFFIXES = (".dll", ".dylib", ".exe", ".pyd", ".so")
1919

‎src/openshell/__init__.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
ClientCredentialsAuth,
1010
ExecChunk,
1111
ExecResult,
12-
InferenceRouteClient,
13-
InferenceRouteConfig,
1412
Sandbox,
1513
SandboxClient,
1614
SandboxError,
@@ -35,8 +33,6 @@
3533
"ClientCredentialsAuth",
3634
"ExecChunk",
3735
"ExecResult",
38-
"InferenceRouteClient",
39-
"InferenceRouteConfig",
4036
"Sandbox",
4137
"SandboxClient",
4238
"SandboxError",

‎src/openshell/sandbox.py‎

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
from ._proto import (
2727
datamodel_pb2,
28-
inference_pb2,
29-
inference_pb2_grpc,
3028
openshell_pb2,
3129
openshell_pb2_grpc,
3230
)
@@ -1204,74 +1202,6 @@ def delete(self, name: str, *, workspace: str) -> bool:
12041202
return bool(response.deleted)
12051203

12061204

1207-
@dataclass(frozen=True)
1208-
class InferenceRouteConfig:
1209-
provider_name: str
1210-
model_id: str
1211-
version: int
1212-
1213-
1214-
class InferenceRouteClient:
1215-
"""gRPC client for workspace-scoped inference route configuration."""
1216-
1217-
def __init__(self, channel: grpc.Channel, *, timeout: float = 30.0) -> None:
1218-
self._stub = inference_pb2_grpc.InferenceStub(channel)
1219-
self._timeout = timeout
1220-
1221-
@classmethod
1222-
def from_sandbox_client(cls, client: SandboxClient) -> InferenceRouteClient:
1223-
return cls(client._channel, timeout=client._timeout)
1224-
1225-
def set_route(
1226-
self,
1227-
*,
1228-
workspace: str,
1229-
provider_name: str,
1230-
model_id: str,
1231-
no_verify: bool = False,
1232-
) -> InferenceRouteConfig:
1233-
response = self._stub.SetInferenceRoute(
1234-
inference_pb2.SetInferenceRouteRequest(
1235-
workspace=workspace,
1236-
provider_name=provider_name,
1237-
model_id=model_id,
1238-
no_verify=no_verify,
1239-
),
1240-
timeout=self._timeout,
1241-
)
1242-
return InferenceRouteConfig(
1243-
provider_name=response.provider_name,
1244-
model_id=response.model_id,
1245-
version=response.version,
1246-
)
1247-
1248-
def get_route(self, *, workspace: str) -> InferenceRouteConfig:
1249-
response = self._stub.GetInferenceRoute(
1250-
inference_pb2.GetInferenceRouteRequest(workspace=workspace),
1251-
timeout=self._timeout,
1252-
)
1253-
return InferenceRouteConfig(
1254-
provider_name=response.provider_name,
1255-
model_id=response.model_id,
1256-
version=response.version,
1257-
)
1258-
1259-
def delete_route(
1260-
self,
1261-
*,
1262-
workspace: str,
1263-
route_name: str = "",
1264-
) -> bool:
1265-
response = self._stub.DeleteInferenceRoute(
1266-
inference_pb2.DeleteInferenceRouteRequest(
1267-
workspace=workspace,
1268-
route_name=route_name,
1269-
),
1270-
timeout=self._timeout,
1271-
)
1272-
return response.deleted
1273-
1274-
12751205
@dataclass(frozen=True)
12761206
class WorkspaceRef:
12771207
name: str

‎tests/sandbox_test.py‎

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
_PYTHON_CLOUDPICKLE_BOOTSTRAP,
2424
_SANDBOX_PYTHON_BIN,
2525
ClientCredentialsAuth,
26-
InferenceRouteClient,
2726
Sandbox,
2827
SandboxClient,
2928
SandboxError,
@@ -403,34 +402,6 @@ def ExecSandbox(
403402
)
404403

405404

406-
class _FakeInferenceStub:
407-
def __init__(self) -> None:
408-
self.set_request = None
409-
self.get_request = None
410-
411-
def SetInferenceRoute(self, request: Any, timeout: float | None = None) -> Any:
412-
self.set_request = request
413-
_ = timeout
414-
415-
class _Response:
416-
provider_name = request.provider_name
417-
model_id = request.model_id
418-
version = 1
419-
420-
return _Response()
421-
422-
def GetInferenceRoute(self, request: Any, timeout: float | None = None) -> Any:
423-
self.get_request = request
424-
_ = timeout
425-
426-
class _Response:
427-
provider_name = "openai-dev"
428-
model_id = "gpt-4.1"
429-
version = 2
430-
431-
return _Response()
432-
433-
434405
def _client_with_fake_stub(stub: object) -> SandboxClient:
435406
client = cast("SandboxClient", object.__new__(SandboxClient))
436407
client._timeout = 30.0
@@ -1877,39 +1848,6 @@ def fake_from_active_cluster(**kwargs: Any) -> Any:
18771848
assert captured["insecure"] is False
18781849

18791850

1880-
def test_inference_set_route_forwards_workspace_and_no_verify() -> None:
1881-
stub = _FakeInferenceStub()
1882-
client = cast("InferenceRouteClient", object.__new__(InferenceRouteClient))
1883-
client._timeout = 30.0
1884-
client._stub = cast("Any", stub)
1885-
1886-
client.set_route(
1887-
workspace="production",
1888-
provider_name="openai-dev",
1889-
model_id="gpt-4.1",
1890-
no_verify=True,
1891-
)
1892-
1893-
assert stub.set_request is not None
1894-
assert stub.set_request.no_verify is True
1895-
assert stub.set_request.workspace == "production"
1896-
1897-
1898-
def test_inference_get_route_forwards_workspace() -> None:
1899-
stub = _FakeInferenceStub()
1900-
client = cast("InferenceRouteClient", object.__new__(InferenceRouteClient))
1901-
client._timeout = 30.0
1902-
client._stub = cast("Any", stub)
1903-
1904-
config = client.get_route(workspace="staging")
1905-
1906-
assert stub.get_request is not None
1907-
assert stub.get_request.workspace == "staging"
1908-
assert config.provider_name == "openai-dev"
1909-
assert config.model_id == "gpt-4.1"
1910-
assert config.version == 2
1911-
1912-
19131851
# ---------------------------------------------------------------------------
19141852
# Encoding regression tests (utf-8 explicit on all config file reads/writes)
19151853
# ---------------------------------------------------------------------------

‎tests/wheel_verifier_test.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _wheel_files() -> set[str]:
3232
"openshell/py.typed",
3333
"openshell/_proto/__init__.py",
3434
}
35-
for stem in ("datamodel", "inference", "openshell", "options", "sandbox"):
35+
for stem in ("datamodel", "openshell", "options", "sandbox"):
3636
files.add(f"openshell/_proto/{stem}_pb2.py")
3737
files.add(f"openshell/_proto/{stem}_pb2.pyi")
3838
files.add(f"openshell/_proto/{stem}_pb2_grpc.py")

0 commit comments

Comments
 (0)