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

Add relative paths to nodes as variables #2629

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

cbentejac
Copy link
Contributor

@cbentejac cbentejac commented Dec 26, 2024

Description

This PR adds new variables that can be used in the description of nodes to write relative paths. For each Node object, there are currently two variables that are available by default:

  • ${NODE_CACHE_FOLDER}, which points towards the cache folder for this node (and is effectively the same as desc.Node.internalFolder);
  • ${NODE_SOURCECODE_FOLDER}, which points towards the folder containing the node's description.

These variables are stored in a dictionary named rootFolder which is part of the Node class. rootFolder can be edited to add or remove variables, with the key of each entry being the name of variable and its value the path it corresponds to. Those variables will be resolved at the same time as environment variables during the evaluation of the attribute's value.

All the nodes are modified to use ${NODE_CACHE_FOLDER} instead of desc.Node.internalFolder, and ScenePreview is updated to use ${NODE_SOURCECODE_FOLDER} when providing the path to the Blender script.

Unit tests are added.

Features

  • Add rootFolder dictionary to the BaseNode class
  • Evaluate variables attributes' values using rootFolder
  • Update all the nodes to use relative paths variables when possible
  • Add corresponding unit tests

Implementation remarks

Node objects have a new property sourceCodeFolder which contains the path to their directory, and which is used to resolve ${NODE_SOURCECODE_FOLDER}.

@cbentejac cbentejac added this to the Meshroom 2024.1.0 milestone Dec 26, 2024
@cbentejac cbentejac self-assigned this Dec 26, 2024
@cbentejac cbentejac force-pushed the dev/relativePaths branch 2 times, most recently from 53206f9 to 34e1495 Compare December 27, 2024 08:52
Copy link

codecov bot commented Dec 27, 2024

Codecov Report

Attention: Patch coverage is 94.66667% with 8 lines in your changes missing coverage. Please review.

Project coverage is 70.47%. Comparing base (e43cd62) to head (11d9b40).

Files with missing lines Patch % Lines
meshroom/nodes/aliceVision/ImageProcessing.py 25.00% 3 Missing ⚠️
tests/test_nodeDynamicEnvVars.py 97.56% 3 Missing ⚠️
meshroom/core/desc/attribute.py 0.00% 1 Missing ⚠️
tests/nodes/test/RelativePaths.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2629      +/-   ##
===========================================
+ Coverage    69.93%   70.47%   +0.53%     
===========================================
  Files          121      123       +2     
  Lines         7088     7231     +143     
===========================================
+ Hits          4957     5096     +139     
- Misses        2131     2135       +4     

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

@cbentejac cbentejac force-pushed the dev/relativePaths branch 8 times, most recently from 8c37fd0 to 3042f94 Compare December 27, 2024 13:42
@cbentejac cbentejac marked this pull request as ready for review December 27, 2024 14:31
@@ -124,6 +124,6 @@ class CameraCalibration(desc.AVCommandLineNode):
name="output",
label="Output",
description="Output filename for intrinsic [and extrinsic] parameters.",
value=desc.Node.internalFolder + "/cameraCalibration.cal",
value="${NODE_CACHE_FOLDER}" + "cameraCalibration.cal",
Copy link
Member

Choose a reason for hiding this comment

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

Should be a single string:
value="${NODE_CACHE_FOLDER}/cameraCalibration.cal",

meshroom/core/node.py Outdated Show resolved Hide resolved
meshroom/core/node.py Outdated Show resolved Hide resolved
meshroom/core/node.py Outdated Show resolved Hide resolved
This property stores the location of the source code for a given node
and is not exposed to the QML side.
`dynamicEnvVars` is a dictionary currently mapping a name to a folder
to use as the root when writing relative paths. Keys correspond to
the variable names that are to be replaced with their values during
the evaluation of attributes.

Although it currently only contains folder paths, any type of variable
may be written in this dictionary to resolve attribute values with.
When the value of an attribute is evaluated, we should look for any
substitution that can be made from the `dynamicEnvVars` dictionary. The
values to substitute from are thus not part of the command line and can
just be identified with "${varname}", as we do for environment variables.
For all nodes, use the new syntax for relative paths.
…ER}`

This prevents having an absolute path for the script, which led to errors
when opening, for example, a project in another environment.
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