Skip to content

Simplify Plugin file tree #3120

@Alxiice

Description

@Alxiice

Description

When writing plugins we need to do the following :

  • create the following arborescence
└── pluginFolder
    └── meshroom
        └── pluginModule
            ├── __init__.py
            └── plugin_node.py
  • Set the env variable :
    • export MESHROOM_PLUGINS_PATH=$MESHROOM_PLUGINS_PATH:/path/to/pluginFolder
    • Or with rez : env.MESHROOM_REZ_PLUGINS.append("myPlugin=/path/to/pluginFolder")

Important

Because of that we often end up having meshroom folders with only a single plugin inside so the meshroom folder could be simply removed.

Proposition

Changes in loadPluginFolder

mrFolder = Path(folder, 'meshroom')
if not mrFolder.exists():
logging.info(f"Plugin folder '{folder}' does not contain a 'meshroom' folder.")
return

I suggest to replace with :

 mrFolder = Path(folder, 'meshroom') 
 if not mrFolder.exists(): 
     mrFolder = folder 

That way we keep the retrocompatibility but now the arborescence could be :

└── pluginFolder
    └── pluginModule
        ├── __init__.py
        └── plugin_node.py

Which would be simpler.

Changes in loadClasses

if not isPackage:
logging.warning(f"No class defined in plugin: {package.__name__}.{pluginName} ('{pluginMod.__file__}')")

Also here the warning is adding too much logs I think we should put it in info at most.

Changes in initPlugins

pluginsFolders = [os.path.join(meshroomFolder, "plugins")] + additionalPluginsPath

Here we add a "plugins" folder that doesn't exist in Meshroom. This result in an unwanted log because of that code :

if not os.path.isdir(folder):
logging.info(f"Plugin folder '{folder}' does not exist.")
return

It's not a big issue because the default log level is warning, but I think we should rewrite the function this way :

def initPlugins():
    # Classic plugins (with a DirTreeProcessEnv)
    pluginsFolders = EnvVar.getList(EnvVar.MESHROOM_PLUGINS_PATH)
    for f in pluginsFolders:
        ...
    ...

Metadata

Metadata

Assignees

Labels

featurenew feature (proposed as PR or issue planned by dev)
No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions