Consolidate core types: move record.py, add structured output types, enforce strict typing#186
Conversation
- Move record.py from async_utils/transport to core/ - Add PromptData, TextModelOutput, ErrorData types with msgspec Struct - Deprecate str as response_output type in favor of TextModelOutput - Add msgspec struct performance flags (gc=False, array_like=True) - Fix threading safety issues in http_client, sample handler, recorder - Update all imports across the codebase - Bump default worker init timeout to 60s
|
MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅ |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors core data types within the inference endpoint system to improve type safety, performance, and maintainability. By introducing dedicated Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and valuable refactoring by consolidating core data types. Moving record.py to core/ improves the project structure. The replacement of raw string outputs with the new TextModelOutput struct, along with the addition of PromptData and ErrorData, greatly enhances type safety and performance. The threading safety fix in SingletonMixin is also a welcome improvement. The changes are applied consistently across the codebase, including extensive updates to tests. I've found a couple of minor issues with incorrect comments in the SGLang adapter tests, which I've flagged for correction. Overall, this is a high-quality contribution that improves the maintainability and robustness of the system.
The SGLang adapter now returns TextModelOutput, not raw str. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
What does this PR do?
record.pyfromasync_utils/transport/tocore/— it's a core data type, not transport-specificstrresponse output withTextModelOutputstruct for type safety and downstream metric computationPromptDataandErrorDatamsgspec Structs withgc=False,array_like=Truefor hot-path performanceHTTPEndpointClient,SampleEventHandler,EventRecorder, andshutdown_executor()Type of change
Related issues
Testing
Checklist