Skip to content
Browse files

[processing] In batch mode, don't try to run rows with invalid parame…

…ter values

Previously we would show a warning about these, but then go ahead and try
to run the row anyway (using an empty set of parameters), resulting in
the log being filled with confusing error messages.

Instead, keep the existing warning advising about which values are
invalid, but skip the affected row and don't try to run it at all.
  • Loading branch information
nyalldawson committed Mar 18, 2020
1 parent 49233b8 commit 08e850db38242a0fd4548e22f135bd8202e91d5d
@@ -102,8 +102,11 @@ def runAlgorithm(self):
project = QgsProject.instance() if load_layers else None

for row in range(self.mainWidget().batchRowCount()):
parameters = self.mainWidget().parametersForRow(row, destinationProject=project, warnOnInvalid=True)
parameters, ok = self.mainWidget().parametersForRow(row, destinationProject=project, warnOnInvalid=True)
if ok:
if not alg_parameters:

task = QgsScopedProxyProgressTask('Batch Processing - {0}').format(self.algorithm().displayName()))
multi_feedback = BatchFeedback(len(alg_parameters), feedback)
@@ -210,7 +210,7 @@ def populateByExpression(self, adding=False):
expression_context = context.expressionContext()

# use the first row parameter values as a preview during expression creation
params = self.panel.parametersForRow(0, warnOnInvalid=False)
params, ok = self.panel.parametersForRow(0, warnOnInvalid=False)
alg_scope = QgsExpressionContextUtils.processingAlgorithmScope(self.panel.alg, params, context)

# create explicit variables corresponding to every parameter
@@ -247,7 +247,7 @@ def populateByExpression(self, adding=False):
self.setRowValue(row + first_row, value, context)
for row in range(self.panel.batchRowCount()):
params = self.panel.parametersForRow(row, warnOnInvalid=False)
params, ok = self.panel.parametersForRow(row, warnOnInvalid=False)

# remove previous algorithm scope -- we need to rebuild this completely, using the
# other parameter values from the current row
@@ -600,7 +600,7 @@ def parametersForRow(self, row, destinationProject=None, warnOnInvalid=True):'Wrong or missing parameter value: {0} (row {1})').format(
param.description(), row + 1),
level=Qgis.Warning, duration=5)
return {}
return {}, False
col += 1
count_visible_outputs = 0
for out in self.alg.destinationParameterDefinitions():
@@ -623,5 +623,5 @@ def parametersForRow(self, row, destinationProject=None, warnOnInvalid=True):
self.parent.messageBar().pushMessage("",'Wrong or missing output value: {0} (row {1})').format(
out.description(), row + 1),
level=Qgis.Warning, duration=5)
return {}
return parameters
return {}, False
return parameters, True

0 comments on commit 08e850d

Please sign in to comment.
You can’t perform that action at this time.