mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-31 07:44:57 +08:00
fix(sdk): gracefully handle missing proto stubs in __init__.py
Wrap the sandbox import in try/except so subpackages like openshell.prover can be imported without a full Rust build. Removes the conftest.py namespace hack that was working around this. Signed-off-by: Alexander Watson <zredlined@gmail.com>
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
"""Root conftest for Python tests.
|
||||
|
||||
Pre-register openshell as a namespace package so subpackage tests (e.g.,
|
||||
the prover) can run without the full Rust build that generates proto stubs.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import types
|
||||
from pathlib import Path
|
||||
|
||||
if "openshell" not in sys.modules:
|
||||
_pkg = types.ModuleType("openshell")
|
||||
_pkg.__path__ = [str(Path(__file__).resolve().parent / "openshell")]
|
||||
_pkg.__package__ = "openshell"
|
||||
sys.modules["openshell"] = _pkg
|
||||
@@ -5,18 +5,23 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .sandbox import (
|
||||
ClusterInferenceConfig,
|
||||
ExecChunk,
|
||||
ExecResult,
|
||||
InferenceRouteClient,
|
||||
Sandbox,
|
||||
SandboxClient,
|
||||
SandboxError,
|
||||
SandboxRef,
|
||||
SandboxSession,
|
||||
TlsConfig,
|
||||
)
|
||||
try:
|
||||
from .sandbox import (
|
||||
ClusterInferenceConfig,
|
||||
ExecChunk,
|
||||
ExecResult,
|
||||
InferenceRouteClient,
|
||||
Sandbox,
|
||||
SandboxClient,
|
||||
SandboxError,
|
||||
SandboxRef,
|
||||
SandboxSession,
|
||||
TlsConfig,
|
||||
)
|
||||
except ImportError:
|
||||
# Proto stubs not yet generated (requires Rust build).
|
||||
# Subpackages like openshell.prover can still be imported.
|
||||
pass
|
||||
|
||||
try:
|
||||
from importlib.metadata import version
|
||||
|
||||
Reference in New Issue
Block a user