Skip to content

Commit da1a5e4

Browse files
authored
Merge pull request #2868 from alicevision/dev/renamePublish
[nodes] Rename the `Publish` node to `CopyFiles`
2 parents cd0601a + ed99822 commit da1a5e4

File tree

5 files changed

+55
-53
lines changed

5 files changed

+55
-53
lines changed

bin/meshroom_batch

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ general_group.add_argument(
5757
default=os.environ.get('MESHROOM_DEFAULT_PIPELINE', 'photogrammetry'),
5858
help='Template pipeline among those listed or a Meshroom file containing a custom pipeline '
5959
'to run on input images:\n' +
60-
'\n'.join([' - ' + p for p in meshroom.core.pipelineTemplates]) +
61-
'\nRequirements: the graph must contain at least one CameraInit node, and at least '
62-
'one Publish node if --output is set.',
60+
'\n'.join([' - ' + p for p in meshroom.core.pipelineTemplates]) +
61+
'\nRequirements: the graph must contain one CameraInit node, and at least '
62+
'one CopyFiles node if --output is set.',
6363
)
6464

6565
general_group.add_argument(
66-
'-o', '--output', metavar='FOLDER PUBLISH_INSTANCE=FOLDER',
66+
'-o', '--output', metavar='FOLDER COPYFILES_INSTANCE=FOLDER',
6767
type=str, required=False, nargs='*',
6868
help='Output folder where results should be copied to. '
69-
'If the output folder is provided without specifiying the instance of a Publish node, '
70-
'all the Publish nodes in the scene will be set with the same ouput folder value. '
69+
'If the output folder is provided without specifiying the instance of a CopyFiles node, '
70+
'all the CopyFiles nodes in the scene will be set with the same ouput folder value. '
7171
'If not set, results will have to be retrieved directly from the cache folder.')
7272

7373
general_group.add_argument(
@@ -151,10 +151,10 @@ with meshroom.core.graph.GraphModification(graph):
151151
loweredPipelineTemplates = {k.lower(): v for k, v in meshroom.core.pipelineTemplates.items()}
152152
if args.pipeline.lower() in loweredPipelineTemplates:
153153
graph.initFromTemplate(loweredPipelineTemplates[args.pipeline.lower()],
154-
publishOutputs=True if args.output else False)
154+
copyOutputs=True if args.output else False)
155155
else:
156156
# custom pipeline
157-
graph.initFromTemplate(args.pipeline, publishOutputs=True if args.output else False)
157+
graph.initFromTemplate(args.pipeline, copyOutputs=True if args.output else False)
158158

159159
def parseInputs(inputs, uniqueInitNode):
160160
"""Utility method for parsing the input and inputRecursive arguments."""
@@ -218,46 +218,46 @@ with meshroom.core.graph.GraphModification(graph):
218218
graph.setVerbose(args.verbose)
219219

220220
if args.output:
221-
# The output folders for Publish nodes can be set as follows:
221+
# The output folders for CopyFiles nodes can be set as follows:
222222
# - for each node, the output folder is specified following the
223-
# "Publish_name=/output/folder/path" convention.
224-
# - a path is provided without specifying which Publish node should be set with it:
225-
# all the Publish nodes will be set with it.
226-
# - some Publish nodes have their path specified, and another path is provided
227-
# without specifying a node: all Publish nodes with dedicated will have their own
223+
# "CopyFiles_name=/output/folder/path" convention.
224+
# - a path is provided without specifying which CopyFiles node should be set with it:
225+
# all the CopyFiles nodes will be set with it.
226+
# - some CopyFiles nodes have their path specified, and another path is provided
227+
# without specifying a node: all CopyFiles nodes with dedicated will have their own
228228
# output folders set, and those which have not been specified will be set with the
229229
# other path.
230-
# - some Publish nodes have their output folder specified while others do not: all
230+
# - some CopyFiles nodes have their output folder specified while others do not: all
231231
# the nodes with specified folders will use the provided values, and those without
232-
# any will be set with the output folder of the first specified Publish node.
232+
# any will be set with the output folder of the first specified CopyFiles node.
233233
# - several output folders are provided without specifying any node: the last one will
234-
# be used to set all the Publish nodes' output folders.
234+
# be used to set all the CopyFiles nodes' output folders.
235235

236-
# Check that there is at least one Publish node
237-
publishNodes = graph.nodesOfType('Publish')
238-
if len(publishNodes) == 0:
236+
# Check that there is at least one CopyFiles node
237+
copyNodes = graph.nodesOfType('CopyFiles')
238+
if len(copyNodes) == 0:
239239
raise RuntimeError('meshroom_batch requires a pipeline graph with at least ' +
240-
'one Publish node, none found.')
240+
'one CopyFiles node, none found.')
241241

242242
reExtract = re.compile(r'(\w+)=(.*)') # NodeName=value
243-
globalPublishPath = ""
243+
globalCopyPath = ''
244244
for p in args.output:
245245
result = reExtract.match(p)
246246
if not result: # If the argument is only a path, set it for the global path
247-
globalPublishPath = p
247+
globalCopyPath = p
248248
continue
249249

250250
node, value = result.groups()
251-
for i, n in enumerate(publishNodes): # Find the correct Publish node in the list
251+
for i, n in enumerate(copyNodes): # Find the correct CopyFiles node in the list
252252
if n.name == node: # If found, set the value, and remove it from the list
253253
n.output.value = value
254-
publishNodes.pop(i)
255-
if globalPublishPath == "": # Fallback in case some nodes would have no path
256-
globalPublishPath = value
254+
copyNodes.pop(i)
255+
if globalCopyPath == '': # Fallback in case some nodes would have no path
256+
globalCopyPath = value
257257
break
258258

259-
for n in publishNodes: # Set the remaining Publish nodes with the global path
260-
n.output.value = globalPublishPath
259+
for n in copyNodes: # Set the remaining CopyPath nodes with the global path
260+
n.output.value = globalCopyPath
261261
else:
262262
print(f'No output set, results will be available in the cache folder: "{graph.cacheDir}"')
263263

meshroom/core/graph.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def load(self, filepath: PathLike):
256256
self._deserialize(Graph._loadGraphData(filepath))
257257
self._fileDateVersion = os.path.getmtime(filepath)
258258

259-
def initFromTemplate(self, filepath: PathLike, publishOutputs: bool = False):
259+
def initFromTemplate(self, filepath: PathLike, copyOutputs: bool = False):
260260
"""
261261
Deserialize a template Meshroom Graph ".mg" file in place.
262262
@@ -265,7 +265,7 @@ def initFromTemplate(self, filepath: PathLike, publishOutputs: bool = False):
265265
266266
Args:
267267
filepath: The path to the Meshroom Graph file to load.
268-
publishOutputs: (optional) Whether to keep 'Publish' nodes.
268+
copyOutputs: (optional) Whether to keep 'CopyFiles' nodes.
269269
"""
270270
self._deserialize(Graph._loadGraphData(filepath))
271271

@@ -274,9 +274,9 @@ def initFromTemplate(self, filepath: PathLike, publishOutputs: bool = False):
274274
# node instance created by this process.
275275
self._triggerNodeCreatedCallback(self.nodes)
276276

277-
if not publishOutputs:
277+
if not copyOutputs:
278278
with GraphModification(self):
279-
for node in [node for node in self.nodes if node.nodeType == "Publish"]:
279+
for node in [node for node in self.nodes if node.nodeType == "CopyFiles"]:
280280
self.removeNode(node.name)
281281

282282
@staticmethod

meshroom/nodes/general/Publish.py renamed to meshroom/nodes/general/CopyFiles.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@
99
import os
1010

1111

12-
class Publish(desc.Node):
13-
size = desc.DynamicNodeSize('inputFiles')
12+
class CopyFiles(desc.Node):
13+
size = desc.DynamicNodeSize("inputFiles")
1414

15-
category = 'Export'
16-
documentation = '''
15+
category = "Export"
16+
documentation = """
1717
This node allows to copy files into a specific folder.
18-
'''
18+
"""
1919

2020
inputs = [
2121
desc.ListAttribute(
2222
elementDesc=desc.File(
2323
name="input",
2424
label="Input",
25-
description="File or folder to publish.",
25+
description="File or folder to copy.",
2626
value="",
2727
),
2828
name="inputFiles",
2929
label="Input Files",
30-
description="Input files or folders' content to publish.",
30+
description="Input files or folders' content to copy.",
3131
exposed=True,
3232
group="",
3333
),
3434
desc.File(
3535
name="output",
3636
label="Output Folder",
37-
description="Folder to publish to.",
37+
description="Folder to copy to.",
3838
value="",
3939
),
4040
desc.ChoiceParam(
@@ -51,39 +51,41 @@ def resolvedPaths(self, inputFiles, outDir):
5151
for inputFile in inputFiles:
5252
for f in glob.glob(inputFile.value):
5353
if os.path.isdir(f):
54-
paths[f] = outDir # Do not concatenate the input folder's name with the output's
54+
# Do not concatenate the input folder's name with the output's
55+
paths[f] = outDir
5556
else:
5657
paths[f] = os.path.join(outDir, os.path.basename(f))
5758
return paths
5859

5960
def processChunk(self, chunk):
6061
try:
6162
chunk.logManager.start(chunk.node.verboseLevel.value)
62-
63+
6364
if not chunk.node.inputFiles:
64-
chunk.logger.warning('Nothing to publish')
65+
chunk.logger.warning("No file to copy.")
6566
return
6667
if not chunk.node.output.value:
6768
return
6869

6970
outFiles = self.resolvedPaths(chunk.node.inputFiles.value, chunk.node.output.value)
7071

7172
if not outFiles:
72-
error = 'Publish: input files listed, but nothing to publish'
73+
error = "CopyFiles: input files listed, but nothing to copy."
7374
chunk.logger.error(error)
74-
chunk.logger.info(f'Listed input files: {[i.value for i in chunk.node.inputFiles.value]}')
75+
chunk.logger.info(f"Listed input files: {[i.value for i in chunk.node.inputFiles.value]}.")
7576
raise RuntimeError(error)
7677

7778
if not os.path.exists(chunk.node.output.value):
7879
os.makedirs(chunk.node.output.value)
7980

8081
for iFile, oFile in outFiles.items():
81-
if os.path.isdir(iFile): # If the input is a directory, copy the directory's content
82-
chunk.logger.info(f'Publish directory {iFile} into {oFile}')
82+
# If the input is a directory, copy the directory's content
83+
if os.path.isdir(iFile):
84+
chunk.logger.info(f"CopyFiles directory {iFile} into {oFile}.")
8385
du.copy_tree(iFile, oFile)
8486
else:
85-
chunk.logger.info(f'Publish file {iFile} into {oFile}')
87+
chunk.logger.info(f"CopyFiles file {iFile} into {oFile}.")
8688
shutil.copyfile(iFile, oFile)
87-
chunk.logger.info('Publish end')
89+
chunk.logger.info("CopyFiles end.")
8890
finally:
8991
chunk.logManager.end()

meshroom/ui/graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,10 @@ def loadGraph(self, filepath):
469469
self.setGraph(g)
470470

471471
@Slot(str, bool, result=bool)
472-
def initFromTemplate(self, filepath, publishOutputs=False):
472+
def initFromTemplate(self, filepath, copyOutputs=False):
473473
graph = Graph("")
474474
if filepath:
475-
graph.initFromTemplate(filepath, publishOutputs=publishOutputs)
475+
graph.initFromTemplate(filepath, copyOutputs=copyOutputs)
476476
self.setGraph(graph)
477477

478478
@Slot(QUrl, result="QVariantList")

meshroom/ui/qml/Application.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ Page {
608608
Action {
609609
id: loadTemplateAction
610610

611-
property string tooltip: "Load a template like a regular project file (any \"Publish\" node will be displayed)"
611+
property string tooltip: "Load a template like a regular project file (any \"CopyFiles\" node will be displayed)"
612612
text: "Load Template"
613613
onTriggered: {
614614
ensureSaved(function() {

0 commit comments

Comments
 (0)