feat: Optimisation#139
Conversation
There was a problem hiding this comment.
Hello @toby-coleman, 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!
Summary of Changes
This pull request introduces a Tuner class to enable optimization of Plugboard processes using Ray Tune. It addresses issue #104. The changes include the Tuner class itself, associated schemas for specifying the optimization configuration, and updates to the ProcessConfigSpec to include an optional TuneSpec.
Highlights
- Tuner Class: Introduces a
Tunerclass for performing optimization of Plugboard processes using Ray Tune. - Schemas: Adds schemas for configuring the optimization process, including
TuneSpec,ObjectiveSpec,ParameterSpec, andOptunaSpec. - Process Configuration: Modifies the
ProcessConfigSpecto include an optionalTuneSpecfor specifying an optimization configuration.
Changelog
Click here to see the changelog
- plugboard/schemas/init.py
- Added imports for new tune-related schemas:
Direction,ObjectiveSpec,OptunaSpec,ParameterSpec,TuneArgsDict,TuneArgsSpec, andTuneSpec. - Added the new schemas to the
__all__list.
- Added imports for new tune-related schemas:
- plugboard/schemas/_common.py
- Added
validate_assignment=Trueto themodel_configto enable validation on assignment. - Added
overridemethod toPlugboardBaseModel.
- Added
- plugboard/schemas/config.py
- Imported
TuneSpec. - Added an optional
tuneattribute of typeTuneSpec | Noneto theProcessConfigSpec.
- Imported
- plugboard/schemas/tune.py
- Created a new file defining schemas for configuring optimization jobs, including
OptunaSpec,BaseFieldSpec,ObjectiveSpec,FloatParameterSpec,IntParameterSpec,CategoricalParameterSpec,ParameterSpec,TuneArgsDict,TuneArgsSpec, andTuneSpec.
- Created a new file defining schemas for configuring optimization jobs, including
- plugboard/tune/init.py
- Created a new file to define the tune submodule.
- Added
Tunerto__all__.
- plugboard/tune/tune.py
- Created a new file defining the
Tunerclass for running optimization on Plugboard processes using Ray Tune.
- Created a new file defining the
- pyproject.toml
- Added
optuna>=4.0,<5to theraydependencies. - Added
tuneto therayextra dependencies. - Updated
openaiversion from 1.72.0 to 1.73.0. - Added
alembic,colorlog, andtensorboardxdependencies.
- Added
- tests/integration/test_tuner.py
- Created a new file to define integration tests for the
Tunerclass.
- Created a new file to define integration tests for the
- uv.lock
- Updated the lock file to reflect the new dependencies.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and 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 to provide feedback.
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.
A tuner's quest, with Ray's bright aid,
To find the best, a process swayed.
With Optuna's art,
It plays its part,
In Plugboard's tune, a change is made.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces a Tuner class to enable optimization using Ray Tune. The changes include the Tuner class itself and associated schemas. Overall, the code appears well-structured and addresses the issue of optimization effectively. However, there are some areas that could benefit from further attention, particularly regarding error handling, documentation, and code clarity.
Summary of Findings
- Missing Error Handling: The code lacks comprehensive error handling, especially around external library calls (e.g., Ray Tune functions). This could lead to unexpected crashes or incorrect behavior if these calls fail. Additional error handling is needed to ensure the code is robust and reliable.
- TODOs in Code: Several
TODOcomments exist in the code, indicating incomplete or potentially problematic areas. These need to be addressed to ensure the code is production-ready. Specifically, theTODOregardingComponentRegistryaccess on Ray workers needs to be resolved. - Incomplete Documentation: While the code includes docstrings, some areas, particularly within the
Tunerclass, could benefit from more detailed explanations. This would improve the code's maintainability and make it easier for others to understand and use.
Merge Readiness
The pull request introduces valuable functionality for optimization. However, before merging, it's crucial to address the identified issues, particularly the missing error handling and TODO comments. Addressing these points will significantly improve the code's robustness and maintainability. I am unable to approve this pull request, and recommend that it not be merged until the critical and high severity issues are addressed (at a minimum), and that others review and approve this code before merging.
|
@chrisk314 - ready for review. One issue of note is the need to set the |
chrisk314
left a comment
There was a problem hiding this comment.
Looks great. One issue with the schemas which looks like a bug, and one typo spotted; otherwise, just a few suggestions for possible minor code improvements.
Co-authored-by: Chris Knight <chrisk314@gmail.com>
Summary
Closes #104 with a
Tunerclass to allow optimisation using Ray Tune.Changes
Tunerclass, which performs the optimisation.plugboard process tune.