-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New Plugin Architecture for Node Registration #2733
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
Conversation
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.
Pull Request Overview
This PR implements support for plugins in Meshroom by introducing a new “plugins” core module with Plugin, NodePlugin, and NodePluginManager classes, refactoring node registration and discovery to use the new pluginManager, and updating tests accordingly.
- Refactor of node registration from nodesDesc to pluginManager.
- Updates of unit tests and integration of plugin-based node discovery.
- Addition of new plugin and node files for PluginA and PluginB.
Reviewed Changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
tests/test_compatibility.py | Refactored node registration and unregistration to use pluginManager. |
tests/test_attributeChoiceParam.py | Updated node registration and tear down to use NodePlugin and pluginManager. |
tests/plugins/meshroom/pluginB/PluginBNodeB.py | Added new plugin node with potential type mismatch in IntParam default value. |
Remaining files | Various code refactoring and formatting changes to switch from nodesDesc to pluginManager integration. |
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## develop #2733 +/- ##
===========================================
+ Coverage 77.15% 78.46% +1.30%
===========================================
Files 41 47 +6
Lines 6167 6542 +375
===========================================
+ Hits 4758 5133 +375
Misses 1409 1409 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
265f51d
to
4e0c15d
Compare
Add a new module named `plugins` with a `ProcessEnv` class which contains the paths describing the environment needed for the plugin's (node's) process.
A `Plugin` object contains a collection of nodes, represented as `NodePlugin` objects. This commit adds the implementation of the `Plugin` class with the methods to add and remove `NodePlugins`, as well as an empty class for the `NodePlugin` objects themselves.
The validation of the node descriptions will be handled directly within the `NodePlugin` objects and there is thus no need for this method to exist outside of plugins.py.
The `NodePluginManager` class manages is used to load, manage, and register plugins and nodes.
Templates that are available for a plugin are detected and gathered upon the plugin's creation.
Nodes are now registered and unregistered through the `NodePluginManager`.
Also comply more with PEP8 linting rules.
The plugin manager is now effectively used for all the operations that involve registering or unregistering nodes.
…...` This prevents ambiguities between `NodePlugin` objects that have been registered (and are thus instantiable) and those that belong to `Plugin` objects but have not been registered.
A `NodePlugin` may be part of a `Plugin` even if it has not been registered. `containsNode` allows to check whether a `NodePlugin` is contained within a `Plugin`, and `belongsToPlugin`
This will replace all the nodes in the current graph with a new instance of the same type. If any change has occured in the description of these nodes since their last instantiation, the new nodes will reflect them.
"Reload All Nodes" will reload all the descriptions for `NodePlugins` that are part of loaded plugins, whether they are registered or not. Once the reload of the descriptions has been performed, the node instances from the current graph will be reloaded as well to reflect any change in the description.
2b64879
to
074a459
Compare
On some systems such as GitHub's Windows CI, the `write` operation is too fast and does not cause a change in the timestamp of the file we're reloading, hence causing the test to fail for external reasons. Adding a sleep does not change anything to the test functionally, but on the contrary ensures that we are actually testing the feature. https://stackoverflow.com/questions/19059877/python-os-path-getmtime-time-not-changing
074a459
to
a6d80b3
Compare
…atus If the plugin has successfully been reloaded, return `True`. If it has not been reloaded for any reason (either an error or because no modification has been made to it since it has been loaded last), then return `False`.
When requesting a `NodePlugin` to reload, the status of the reloading is now saved. If it has been successful, all the nodes of this type in the graph will effectively be removed. If it has not (either because of an error, or because no change has been done to the description), then nothing will happen. Replacing only the nodes whose description has been updated prevents from having to update heavy graphs for very few nodes to change (if any).
Warning only on a module/file without any element in it and provide full-path to ease debugging. For package/folder, it does not generate any message.
699e0dc
to
d3738fb
Compare
Description
This PR adds the support for plugins in Meshroom, building on top of #2703.
A
Plugin
is a collection of at least oneNodePlugin
, which contains the description of a node, and can be associated to templates.Plugins
can be loaded and unloaded with theNodePluginManager
, which is in charge of the registration and unregistration of allNodePlugins
(a node cannot be instantiated until itsNodePlugin
has been registered).All collections of nodes are now considered as plugins, may they be provided through the
MESHROOM_NODES_PATH
or through theMESHROOM_PLUGINS_PATH
environment variables. In the case ofMESHROOM_NODES_PATH
, a Python module containing node descriptions is expected. ForMESHROOM_PLUGINS_PATH
, it is expected that the nodes are contained within a Python module that is itself located in ameshroom
folder.Features list
core
module containing new classes:Plugin
,NodePlugin
,NodePluginManager
;NodePluginManager
;Implementations remarks
Currently, the whole process of going through folders in search of Python packages remains in the
__init__.py
of thecore
module. This is because the method that is used to find files containing nodes is the same as the one used to discover submitters. Submitters are, for now, not included in the "plugins" module and are handled as they were previously.