-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add initialization hook to plugin system #318
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
… CYT-828-add-plugin-command
for more information, see https://pre-commit.ci
… CYT-828-add-plugin-command
for more information, see https://pre-commit.ci
Simpler string formatting. Co-authored-by: Ryan Mast <[email protected]>
Fixed typo. Co-authored-by: Ryan Mast <[email protected]>
for more information, see https://pre-commit.ci
Co-authored-by: Ryan Mast <[email protected]>
- Introduced a new in to allow plugins to perform initialization tasks, such as loading databases or setting up resources. - Implemented the in the plugin to load the JavaScript library database during initialization. - Updated the plugin manager to call the using a helper function, ensuring plugins are initialized based on the command context. - Enhanced modularity and efficiency of the plugin system by allowing conditional initialization. This change improves resource management and prepares the system for future enhancements that require plugin-specific setup.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
- Introduced JSDatabaseManager class to manage the JavaScript library database. - Removed the use of the global statement for js_lib_database to address pylint warning W0603. - Updated functions to access the database through the JSDatabaseManager instance. - Improved code organization and maintainability by encapsulating database logic within a class.
for more information, see https://pre-commit.ci
if hook_filter: | ||
if not any(is_hook_implemented(pm, plugin, hook) for hook in hook_filter): | ||
continue | ||
plugin.init_hook(command_name=command_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably okay to fallback to initializing everything if no hook_filter is provided -- it will just likely be more things happening than needed if we ever leave it unset (probably only a very limited number of external users would be interested in this function, maybe pEyeOn or similar that tries to use some of our plugins).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that make the use of hook_filter non-functional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Falling back to initializing everything that has an init_hook
if hook_filter==None
(or hook_filter==[]
) is the current behavior. If hook_filter
is a non-empty list then the continue
statement and check on line 209 looks like it should be working as expected.
If you meant for hook_filter=None
to not call any init_hook
functions then the call to init_hook
on line 211 should be indented one more level.
changed click.echo to logger.info/error
for more information, see https://pre-commit.ci
Summary
This change improves resource management and prepares the system for future enhancements that require plugin-specific setup.
Proposed changes
init_hook
inhookspecs.py
to allow plugins to perform initialization tasks, such as loading databases or setting up resources.init_hook
in thejs_file
plugin to load the JavaScript library database during initialization.init_hook
using a helper function, ensuring plugins are initialized based on the command context.