Add shared allow_stubs() helper and use it to gate stub fallbacks#22
Draft
NguyenCuong1989 wants to merge 1 commit into
Draft
Add shared allow_stubs() helper and use it to gate stub fallbacks#22NguyenCuong1989 wants to merge 1 commit into
NguyenCuong1989 wants to merge 1 commit into
Conversation
Hướng Dẫn Dành Cho Người ReviewGiới thiệu một helper dùng chung Sơ đồ tuần tự để kiểm soát fallback stub thông qua allow_stubssequenceDiagram
actor User
participant haios_runtime as haios_runtime
participant dr_protocol as dr_protocol
participant config as config
participant importlib as importlib
User->>haios_runtime: import HAIOSRuntime
activate haios_runtime
haios_runtime->>importlib: _load_runtime_module()
alt [runtime module found]
importlib-->>haios_runtime: _runtime_impl
haios_runtime-->>User: HAIOSRuntime = _runtime_impl
else [runtime module missing]
haios_runtime->>config: allow_stubs()
config-->>haios_runtime: bool
alt [allow_stubs() is true]
haios_runtime-->>User: HAIOSRuntime stub class
else [allow_stubs() is false]
haios_runtime-->>User: ModuleNotFoundError
end
end
deactivate haios_runtime
User->>dr_protocol: import DRProtocol
activate dr_protocol
dr_protocol->>importlib: _load_framework_module()
alt [framework module found]
importlib-->>dr_protocol: _dr_impl
dr_protocol-->>User: DRProtocol = _dr_impl
else [framework module missing]
dr_protocol->>config: allow_stubs()
config-->>dr_protocol: bool
alt [allow_stubs() is true]
dr_protocol-->>User: DRProtocol stub class
else [allow_stubs() is false]
dr_protocol-->>User: ModuleNotFoundError
end
end
deactivate dr_protocol
Thay Đổi Cấp Độ File
Mẹo và câu lệnhTương tác với Sourcery
Tùy Biến Trải Nghiệm Của BạnTruy cập dashboard của bạn để:
Nhận Hỗ Trợ
Original review guide in EnglishReviewer's GuideIntroduces a shared allow_stubs() helper controlled by the HYPERAI_ALLOW_STUBS environment variable and uses it to gate whether stub implementations of HAIOSRuntime and DRProtocol are available, raising explicit errors when stubs are disabled. Sequence diagram for gating stub fallbacks via allow_stubssequenceDiagram
actor User
participant haios_runtime as haios_runtime
participant dr_protocol as dr_protocol
participant config as config
participant importlib as importlib
User->>haios_runtime: import HAIOSRuntime
activate haios_runtime
haios_runtime->>importlib: _load_runtime_module()
alt [runtime module found]
importlib-->>haios_runtime: _runtime_impl
haios_runtime-->>User: HAIOSRuntime = _runtime_impl
else [runtime module missing]
haios_runtime->>config: allow_stubs()
config-->>haios_runtime: bool
alt [allow_stubs() is true]
haios_runtime-->>User: HAIOSRuntime stub class
else [allow_stubs() is false]
haios_runtime-->>User: ModuleNotFoundError
end
end
deactivate haios_runtime
User->>dr_protocol: import DRProtocol
activate dr_protocol
dr_protocol->>importlib: _load_framework_module()
alt [framework module found]
importlib-->>dr_protocol: _dr_impl
dr_protocol-->>User: DRProtocol = _dr_impl
else [framework module missing]
dr_protocol->>config: allow_stubs()
config-->>dr_protocol: bool
alt [allow_stubs() is true]
dr_protocol-->>User: DRProtocol stub class
else [allow_stubs() is false]
dr_protocol-->>User: ModuleNotFoundError
end
end
deactivate dr_protocol
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
HYPERAI_ALLOW_STUBSto keep behavior consistent across modules.Description
src/hyperai/config.pywith a singleallow_stubs()helper that readsHYPERAI_ALLOW_STUBSand treats{"1","true","t","yes","y","on"}as truthy.src/hyperai/core/haios_runtime.pytofrom hyperai.config import allow_stubs as _allow_stubsand gate the stubHAIOSRuntimefallback using_allow_stubs(), raisingModuleNotFoundErrorif stubs are disabled.src/hyperai/protocols/dr_protocol.pytofrom hyperai.config import allow_stubs as _allow_stubsand gate theDRProtocolstub fallback using_allow_stubs(), raisingModuleNotFoundErrorif stubs are disabled.Testing
python -m compileall src/hyperai/config.py src/hyperai/core/haios_runtime.py src/hyperai/protocols/dr_protocol.pyand compilation completed successfully.Codex Task
Tóm tắt bởi Sourcery
Giới thiệu cấu hình tập trung để kiểm soát việc có cho phép sử dụng các triển khai stub dự phòng hay không và áp dụng cho runtime và tải protocol.
Tính năng mới:
allow_stubs()được điều khiển bởi biến môi trườngHYPERAI_ALLOW_STUBSđể quản lý việc sử dụng các triển khai stub.Cải tiến:
HAIOSRuntimevàDRProtocolthông qua helper dùng chungallow_stubs()thay vì luôn luôn bật chúng.ModuleNotFoundErrorkhi thiếu các triển khai bắt buộc và stub fallback bị vô hiệu hóa.Original summary in English
Summary by Sourcery
Introduce centralized configuration for controlling whether fallback stub implementations are permitted and apply it to runtime and protocol loading.
New Features:
Enhancements: