Skip to content

Conversation

cbentejac
Copy link
Contributor

@cbentejac cbentejac commented Jun 12, 2025

Description

This PR builds on top of #2703 and #2733, which respectively added the notion of local isolated computations for nodes, and the concept of plugins. This pull request adds the notion of runtime-specific environment, allowing nodes to be executed in a dedicated environment that contains their required dependencies independently from Meshroom's.

Two types of execution environments are added in this PR:

  1. DirTreeProcessEnv

Based on the root folder of the plugin, it sets up the environment (PYTHONPATH, PATH and LD_LIBRARY_PATH environment variables). It assumes the plugin has a standard hierarchy:

mrPlugin/
|-- bin
|-- lib
|   `-- pythonX.X
|       `-- site-packages
|           |-- anotherModule
|           `-- myCustomModule
`-- meshroom
    |-- myNodes
    |   |-- NodeA.py
    |   |-- NodeB.py
    |   |-- NodeC.py
    |   `-- __init__.py
    |-- myPipelineA.mg
    `-- myPipelineB.mg

To declare a plugin using the DirTree, set the env variable MESHROOM_PLUGINS_PATH.

  1. RezProcessEnv

Based on a Rez package that's provided through a dedicated environment variable, it gathers all the requirements to execute the process within that Rez environment.

To declare plugins using Rez for their execution, use the MESHROOM_REZ_PLUGINS environment variable.

Rez plugins need to be provided to MESHROOM_REZ_PLUGINS with the following syntax: packageName=/path/to/root. Their package.py also need to follow a certain structure. An example is given below for a package named "mrExample":

name="mrExample"
version="1.0"

plugin_for=["meshroom"]
requires = []

def commands():
    subRequires = [
        'python-3',
        'dependency1-1.0',
        'dependency2-1.0',
        'dependency3'
    ]
    env.MESHROOM_REZ_PLUGINS.append(this.name + "={root}/folder")
    env.MREXAMPLE_SUBREQUIRES = ":".join(subRequires)

Features list

  • Add a new MESHROOM_REZ_PLUGINS environment variable to load Rez plugins;
  • Use an isolated and node-specific runtime environment for all the nodes.

Implementation remarks

For Rez plugins, a few things are to be noted:

  1. Meshroom's ability to detect and set up the runtime environment for Rez plugins relies on the "name=path" pair being correctly provided to MESHROOM_REZ_PLUGINS.
  2. Setting env.MRNAME_SUBREQUIRES in the Rez package's package.py is necessary, as it is used by Meshroom to list the dependencies.
  3. Providing versions of packages for the subrequires is not mandatory: if a version is provided, it will strictly be respected; otherwise, Meshroom will attempt to match the package's version with its own, if it exists in its environment.
  4. When the node is executed in its dedicated Rez environment, both Meshroom's path and the Rez package's are injected into the PYTHONPATH environment variable, strictly within the Rez environment.

@cbentejac cbentejac added this to the Meshroom 2025.1.0 milestone Jun 12, 2025
@cbentejac cbentejac requested a review from fabiencastan June 12, 2025 16:15
@cbentejac cbentejac self-assigned this Jun 12, 2025
@cbentejac cbentejac force-pushed the dev/processEnv branch 2 times, most recently from 43b5b05 to 50bbef7 Compare June 12, 2025 16:25
Copy link

codecov bot commented Jun 12, 2025

Codecov Report

Attention: Patch coverage is 42.76316% with 87 lines in your changes missing coverage. Please review.

Project coverage is 77.87%. Comparing base (c8671de) to head (d027bf8).
Report is 42 commits behind head on develop.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
meshroom/core/plugins.py 37.80% 51 Missing ⚠️
meshroom/core/__init__.py 14.28% 18 Missing ⚠️
meshroom/core/desc/node.py 37.93% 18 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2747      +/-   ##
===========================================
- Coverage    78.57%   77.87%   -0.71%     
===========================================
  Files           48       48              
  Lines         6577     6671      +94     
===========================================
+ Hits          5168     5195      +27     
- Misses        1409     1476      +67     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cbentejac cbentejac marked this pull request as ready for review June 16, 2025 15:56
cbentejac and others added 2 commits June 18, 2025 15:53
…odePlugin`

Otherwise, `node.nodeDesc.plugin` will evaluate to `None` after the node
has been reloaded.
Ensures that the packages installed in a local virtualenv is taken
before the propagation of the global Meshroom environment to avoid
version conflicts.

Note: We tried to avoid checking files/folders on disk at startup for
performance reasons, but here we are forced to use glob as there is no
way to know the python version of the plugin in advance.
@fabiencastan fabiencastan merged commit 3e88732 into develop Jun 18, 2025
3 of 5 checks passed
@fabiencastan fabiencastan deleted the dev/processEnv branch June 18, 2025 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants