[Fix] Prevent client from importing ray via twinkle.server.common.serialize#123
[Fix] Prevent client from importing ray via twinkle.server.common.serialize#123Yunnglin merged 1 commit intomodelscope:mainfrom
twinkle.server.common.serialize#123Conversation
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 resolves a critical 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 effectively resolves the ModuleNotFoundError by decoupling the client-side serialization logic from the server-side implementation. Creating a dedicated serialize.py for the client is a good approach to prevent pulling in server-side dependencies like ray. I've found a couple of potential issues in the newly added serialization file that could lead to runtime errors or confusion, and I've left specific comments with suggestions for improvement.
Yunnglin
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the contribution. Merging now.
When I run python cookbook/client/twinkle/self_host/grpo.py, I get an error.
When client code (e.g., grpo.py ) calls Dataset() to create a dataset, it eventually invokes _serialize_params() in http_utils.py to serialize parameters. When this function encounters an object with dict (such as DatasetMeta ), it executes:
from twinkle.server.common.serialize import serialize_objectHowever, Python executes twinkle.server.common.init.py first when importing twinkle.server.common.serialize . This init.py imports StickyLoraRequestRouter (from router.py ), which further imports ray.serve . As a result, even though the client code doesn't need ray at all, the import chain causes ModuleNotFoundError: No module named 'ray' .
PR type
PR information
Create a standalone serialize.py module under twinkle_client/common/ so that the client uses its own serialization logic without depending on the server package structure.
Experiment results
Paste your experiment result here(if needed).