Optimize serialize / deserialize of Experience#514
Optimize serialize / deserialize of Experience#514pan-x-c wants to merge 7 commits intoagentscope-ai:mainfrom
Conversation
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 and optimizes the way Highlights
Changelog
Activity
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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
/unittest-all |
There was a problem hiding this comment.
Code Review
This pull request refactors the serialization and deserialization of Experience objects, moving from a full pickle-based approach to using safetensors for tensor data while retaining pickle for metadata. This change aims to improve performance for inter-process communication and maintains backward compatibility. However, the continued use of pickle for metadata and legacy payloads introduces a critical security vulnerability, as pickle is susceptible to Remote Code Execution (RCE) from untrusted sources, which is a significant risk in a distributed framework like Trinity. Furthermore, the use of getattr on the torch module with data-derived strings could lead to arbitrary attribute access. The Experiences class and its batching logic have been removed, simplifying experience.py, and tests have been updated. To mitigate the identified security risks, it is strongly recommended to adopt safer serialization formats like JSON or msgpack for metadata and implement allow-lists for dynamic attribute access.
| return [ | ||
| { | ||
| "source_field": field.source_field, | ||
| "destination_field": field.destination_field, | ||
| "data_type": str(field.data_type), | ||
| } | ||
| for field in custom_fields | ||
| ] |
There was a problem hiding this comment.
The loop variable field in the list comprehension shadows the field function imported from dataclasses on line 8. This can be confusing and is generally considered bad practice. Renaming it would improve code clarity and prevent potential issues.
| return [ | |
| { | |
| "source_field": field.source_field, | |
| "destination_field": field.destination_field, | |
| "data_type": str(field.data_type), | |
| } | |
| for field in custom_fields | |
| ] | |
| return [ | |
| { | |
| "source_field": custom_field.source_field, | |
| "destination_field": custom_field.destination_field, | |
| "data_type": str(custom_field.data_type), | |
| } | |
| for custom_field in custom_fields | |
| ] |
Summary
Failed Tests
Skipped
Tests
Github Test Reporter by CTRF 💚 |
|
/unittest-all |
Summary
Skipped
Tests
Github Test Reporter by CTRF 💚 |
Description
As the title says
Checklist
Please check the following items before code is ready to be reviewed.