feat: Basic validation checks for improved user experience#91
feat: Basic validation checks for improved user experience#91toby-coleman merged 20 commits intomainfrom
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 focuses on improving the user experience by adding basic validation checks and informative messages for common user errors. It addresses issue #76. The changes include raising exceptions and logging messages for scenarios like calling run() on an uninitialized Process, unconnected input/output fields in the process graph, and using a custom Component without calling the super constructor.
Highlights
- Process Validation: Calling
run()on an uninitializedProcessnow raises aNotInitialisedErrorexception, preventing unexpected behavior. - Graph Validation: The system now logs errors for processes containing unconnected input fields and warnings for unconnected output fields, aiding in debugging and ensuring proper process execution.
- Component Validation: A
ValidationErroris raised when a customComponentdoesn't call thesuper().__init__constructor, guiding users to correct component implementation. - Logging: Added logging for IOController creation and closure, and for unconnected input/output fields.
Changelog
Click here to see the changelog
- plugboard/component/component.py
- Added
ValidationErrorimport. - Added a check in
connect_stateto raise aValidationErrorifsuper().__init__is not called in the Component's constructor.
- Added
- plugboard/component/io_controller.py
- Added
DIimport. - Added logging on IOController creation and closure.
- Added logging for unconnected input fields (error) and output fields (warning) after connecting.
- Added
- plugboard/exceptions/init.py
- Moved
NotInitialisedErrorto inherit directly fromExceptioninstead ofStateBackendError. - Added
ValidationErrorexception.
- Moved
- plugboard/process/local_process.py
- Added calls to
super().init()andsuper().run()ininitandrunmethods respectively.
- Added calls to
- plugboard/process/process.py
- Added
NotInitialisedErrorimport. - Added
initialisedflag to theProcessclass. - Set
self.initialised = Truein theinitmethod. - Added a check in the
runmethod to raise aNotInitialisedErrorif the process is not initialized.
- Added
- plugboard/process/ray_process.py
- Added calls to
super().init()andsuper().run()ininitandrunmethods respectively.
- Added calls to
- tests/integration/test_process_validation.py
- Added new integration tests to validate the new validation features, including tests for missing connections and invalid component implementations.
- tests/integration/test_process_with_components_run.py
- Added a test to ensure that
process.run()raises aNotInitialisedErrorif called beforeprocess.init().
- Added a test to ensure that
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.
Trivia time!
What is the purpose of the super() function in Python?
Click here for the answer
The `super()` function is used to call a method from a parent class. It allows you to access and use methods of a superclass from a subclass, which is particularly useful for inheritance and extending functionality.
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
The pull request introduces several validation checks and logging improvements to enhance the user experience. It addresses issues such as calling run() on an uninitialized Process, unconnected input/output fields, and missing super().__init__() calls in custom Components. The changes include adding exceptions, logging messages, and tests to cover these scenarios. Overall, the changes seem well-structured and beneficial for improving the robustness and clarity of the framework.
Summary of Findings
- Component Initialization Validation: The addition of a check for
super().__init__()calls in custom Components is a valuable addition, preventing common initialization errors. - Process Initialization Validation: The addition of a check for
process.init()beforeprocess.run()prevents common user errors. - Logging for Unconnected IO: The logging of unconnected input and output fields provides helpful feedback to users about potential issues in their process configurations.
Merge Readiness
The pull request is in good shape and introduces valuable validation and logging improvements. I am unable to directly approve the pull request, and recommend that others review and approve this code before merging. There are no CRITICAL or HIGH severity issues, and the changes enhance the overall quality and usability of the framework. The added tests provide good coverage for the new validation logic.
chrisk314
left a comment
There was a problem hiding this comment.
Looks good! These validations will definitely make the code more user friendly. Just a couple of small code cleanups requested.
Co-authored-by: Chris Knight <chrisk314@gmail.com>
# Summary Closes #76 by adding exceptions/log messages for some common user errors. # Changes * Calling `run()` on an uninitialised `Process` now raises an exception. * Processes containing unconnected input fields in the graph will log an error. * Processes containing unconnected output fields in the graph will log a warning. * Attempting to use a custom `Component` that doesn't call the super constructor will raise a helpful exception.
Summary
Closes #76 by adding exceptions/log messages for some common user errors.
Changes
run()on an uninitialisedProcessnow raises an exception.Componentthat doesn't call the super constructor will raise a helpful exception.