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

Move nodes and templates to AliceVision's repository #2697

Merged
merged 9 commits into from
Mar 19, 2025
10 changes: 4 additions & 6 deletions meshroom/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,11 @@

def initPipelines():
meshroomFolder = os.path.dirname(os.path.dirname(__file__))
# Load pipeline templates: check in the default folder and any folder the user might have
# added to the environment variable
additionalPipelinesPath = os.environ.get("MESHROOM_PIPELINE_TEMPLATES_PATH", "").split(os.pathsep)
additionalPipelinesPath = [i for i in additionalPipelinesPath if i]
pipelineTemplatesFolders = [os.path.join(meshroomFolder, 'pipelines')] + additionalPipelinesPath
# Load pipeline templates: check in any folder the user might have added to the environment variable
pipelinesPath = os.environ.get("MESHROOM_PIPELINE_TEMPLATES_PATH", "").split(os.pathsep)
pipelineTemplatesFolders = [i for i in pipelinesPath if i]
for f in pipelineTemplatesFolders:
if os.path.isdir(f):
loadPipelineTemplates(f)
else:
logging.error("Pipeline templates folder '{}' does not exist.".format(f))
logging.warning("Pipeline templates folder '{}' does not exist.".format(f))

Check warning on line 357 in meshroom/core/__init__.py

View check run for this annotation

Codecov / codecov/patch

meshroom/core/__init__.py#L357

Added line #L357 was not covered by tests
58 changes: 37 additions & 21 deletions tests/test_templatesVersion.py → meshroom/core/test.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,77 @@
#!/usr/bin/env python
# coding:utf-8

from meshroom.core.graph import Graph
from meshroom.core import pipelineTemplates, Version
from meshroom.core import unregisterNodeType, pipelineTemplates, Version
from meshroom.core.node import CompatibilityIssue, CompatibilityNode
from meshroom.core.graphIO import GraphIO

import json
import meshroom

import json

def test_templateVersions():
"""
This test checks that there is no compatibility issue with the nodes saved in the template files.
It fails when an upgrade of a templates is needed. Any template can still be opened even if its
nodes are not up-to-date, as they will be automatically upgraded.
"""
meshroom.core.initNodes()
meshroom.core.initPipelines()

assert len(pipelineTemplates) >= 1
def checkTemplateVersions(path: str, nodesAlreadyLoaded: bool = False) -> bool:
""" Check whether there is a compatibility issue with the nodes saved in the template provided with "path". """
if not nodesAlreadyLoaded:
meshroom.core.initNodes()

for _, path in pipelineTemplates.items():
with open(path) as jsonFile:
fileData = json.load(jsonFile)
with open(path) as jsonFile:
fileData = json.load(jsonFile)

try:
graphData = fileData.get(GraphIO.Keys.Graph, fileData)

assert isinstance(graphData, dict)
if not isinstance(graphData, dict):
return False

header = fileData.get(GraphIO.Keys.Header, {})
assert header.get("template", False)
if not header.get("template", False):
return False
nodesVersions = header.get(GraphIO.Keys.NodesVersions, {})

for _, nodeData in graphData.items():
nodeType = nodeData["nodeType"]
assert nodeType in meshroom.core.nodesDesc
if not nodeType in meshroom.core.nodesDesc:
return False

nodeDesc = meshroom.core.nodesDesc[nodeType]
currentNodeVersion = meshroom.core.nodeVersion(nodeDesc)

inputs = nodeData.get("inputs", {})
internalInputs = nodeData.get("internalInputs", {})
version = nodesVersions.get(nodeType, None)

compatibilityIssue = None

if version and currentNodeVersion and Version(version).major != Version(currentNodeVersion).major:
compatibilityIssue = CompatibilityIssue.VersionConflict
else:
for attrName, value in inputs.items():
if not CompatibilityNode.attributeDescFromName(nodeDesc.inputs, attrName, value):
compatibilityIssue = CompatibilityIssue.DescriptionConflict
break
for attrName, value in internalInputs.items():
if not CompatibilityNode.attributeDescFromName(nodeDesc.internalInputs, attrName, value):
compatibilityIssue = CompatibilityIssue.DescriptionConflict
break

assert compatibilityIssue is None, "{} in {} for node {}".format(compatibilityIssue, path, nodeType)
if compatibilityIssue is not None:
print("{} in {} for node {}".format(compatibilityIssue, path, nodeType))
return False

return True

finally:
if not nodesAlreadyLoaded:
nodeTypes = [nodeType for _, nodeType in meshroom.core.nodesDesc.items()]
for nodeType in nodeTypes:
unregisterNodeType(nodeType)

Check notice on line 66 in meshroom/core/test.py

View check run for this annotation

codefactor.io / CodeFactor

meshroom/core/test.py#L12-L66

Complex Method


def checkAllTemplatesVersions() -> bool:
meshroom.core.initNodes()
meshroom.core.initPipelines()

validVersions = []
for _, path in pipelineTemplates.items():
validVersions.append(checkTemplateVersions(path, nodesAlreadyLoaded=True))

return all(validVersions)
49 changes: 0 additions & 49 deletions meshroom/nodes/aliceVision/ApplyCalibration.py

This file was deleted.

129 changes: 0 additions & 129 deletions meshroom/nodes/aliceVision/CameraCalibration.py

This file was deleted.

Loading