Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check plugin activation error #432

Merged
merged 2 commits into from
Aug 24, 2023
Merged

Check plugin activation error #432

merged 2 commits into from
Aug 24, 2023

Conversation

Pingdred
Copy link
Member

@Pingdred Pingdred commented Aug 23, 2023

Description

Check if there is an error activating the plugin and if so, return HTTP 500.

Also plugin modules are "unimported" when it is disabled.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

@@ -48,15 +50,28 @@ def __init__(self, plugin_path: str, active: bool):

# all plugins start active, they can be deactivated/reactivated from endpoint
if active:
self.activate()
try:
Copy link
Member

Choose a reason for hiding this comment

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

is this necessary? Having already a try/except in the /plugins/toggle/ endpoint and inside self._load_hooks_and_tools?

for py_file in self.py_files:
py_filename = py_file.replace("/", ".").replace(".py", "") # this is UGLY I know. I'm sorry
log(f"Remove module {py_filename}", "DEBUG")
sys.modules.pop(py_filename)
Copy link
Member

Choose a reason for hiding this comment

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

nice!

core/cat/mad_hatter/plugin.py Show resolved Hide resolved
@pieroit
Copy link
Member

pieroit commented Aug 24, 2023

@Pingdred I'm having difficulties undesrstanding where the try/except blocks are necessary and where they are not.
Can we have a look together? Maybe there is something I'm missing :)

@Pingdred
Copy link
Member Author

Sure, I'll ping you on discord later 😄

@pieroit pieroit merged commit dc43195 into cheshire-cat-ai:develop Aug 24, 2023
2 checks passed
@pieroit
Copy link
Member

pieroit commented Aug 24, 2023

Thanks <3

@Pingdred Pingdred deleted the plugin_error branch August 26, 2023 16:07
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.

2 participants