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 dedicated "minimal" mode for templates #1754

Merged
merged 4 commits into from
Sep 6, 2022

Conversation

cbentejac
Copy link
Contributor

Description

Following #1727, project files can be used as templates, with the .mg files containing the entire description of the graph. This implies that if there is a single node whose description is modified (parameters added, parameters removed, etc.), description conflicts will arise when opening a template containing such a node. For these conflicts to be resolved, the template would need to be saved again with the upgraded version of the node every single time there is a change, which defeats the purpose of having templates.

This PR adds a "minimal" mode to save and load templates. Instead of saving the entire graph description, the minimal mode only saves the modified input/output parameters. When that template is opened, conflicts are detected only on the saved parameters (with non-default values) and automatically solved. This makes templates robust to changes in node descriptions.

Features list

  • Support saving only modified input/output parameters of a graph in an .mg file
  • Support reading an .mg file containing only modified input/output parameters
  • Add a "Save As Template" option that saves a graph in minimal mode
  • Update all the existing templates with minimal mode
  • Reload the list of available templates after saving a graph as a template

Implementation remarks

  • Files written in minimal mode can be identified with the flag "template: True" in the header. If that flag is not detected in an .mg file, it is loaded as a regular file and not a template.
  • .mg files written normally (with all the parameters saved) can still be opened as templates, but they will not be robust to any node description changes.
  • test_multiviewPipeline now tests both "minimal" and "regular" modes: the first part of the test opens the default Photogrammetry template (which has been updated to minimal mode) while the second part of the test saves the graph obtained after reading the template into a normal .mg file (in which all the input/output parameters are written).

meshroom/core/node.py Outdated Show resolved Hide resolved
Copy link
Member

@fabiencastan fabiencastan left a comment

Choose a reason for hiding this comment

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

.

If an attribute is a link, when checking whether its value is
the default value, only the resolved value should be compared
with the default one. Otherwise, the attribute's "isDefault"
property will always evaluate to True, even when a non-default
link has been provided.

This issue was especially evident with input File attributes,
for which the default value is generally '' (empty string); if a
link was set as a value (thus non-empty), its unresolved value
would still be '', thus setting the "isDefault" property to True.
meshroom/core/node.py Outdated Show resolved Hide resolved
Add a specific option to save a graph as a template ("Save As
Template") in "minimal" mode.

This mode only saves, for each node in the graph, the input and
output attributes whose values differ from the default ones. Any
attribute that is not serialized in the saved template file is
assumed to have its default value.
If a conflict is detected on a node when opening the template
file, it is logged but solved automatically.

The goal of this minimal mode is to prevent template files from
needing an update every single time a modification (may it be
minor or major) is done on a node description. Templates can
thus follow node changes and still be usable.
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