Skip to content

feat: Basic validation checks for improved user experience#91

Merged
toby-coleman merged 20 commits intomainfrom
feat/usability-enhancements
Mar 5, 2025
Merged

feat: Basic validation checks for improved user experience#91
toby-coleman merged 20 commits intomainfrom
feat/usability-enhancements

Conversation

@toby-coleman
Copy link
Contributor

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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 uninitialized Process now raises a NotInitialisedError exception, 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 ValidationError is raised when a custom Component doesn't call the super().__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 ValidationError import.
    • Added a check in connect_state to raise a ValidationError if super().__init__ is not called in the Component's constructor.
  • plugboard/component/io_controller.py
    • Added DI import.
    • Added logging on IOController creation and closure.
    • Added logging for unconnected input fields (error) and output fields (warning) after connecting.
  • plugboard/exceptions/init.py
    • Moved NotInitialisedError to inherit directly from Exception instead of StateBackendError.
    • Added ValidationError exception.
  • plugboard/process/local_process.py
    • Added calls to super().init() and super().run() in init and run methods respectively.
  • plugboard/process/process.py
    • Added NotInitialisedError import.
    • Added initialised flag to the Process class.
    • Set self.initialised = True in the init method.
    • Added a check in the run method to raise a NotInitialisedError if the process is not initialized.
  • plugboard/process/ray_process.py
    • Added calls to super().init() and super().run() in init and run methods respectively.
  • 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 a NotInitialisedError if called before process.init().
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

  1. 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() before process.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.

Copy link
Contributor

@chrisk314 chrisk314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! These validations will definitely make the code more user friendly. Just a couple of small code cleanups requested.

@toby-coleman toby-coleman merged commit 963331a into main Mar 5, 2025
3 checks passed
@toby-coleman toby-coleman deleted the feat/usability-enhancements branch March 5, 2025 17:34
toby-coleman added a commit that referenced this pull request Mar 15, 2025
# 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Helpful exceptions for common user errors

2 participants