Skip to content
Permalink
Browse files

[processing] Use multi-step feedback for batch execution

Gives better indication of total progress vs showing just
current algorithm progress
  • Loading branch information
nyalldawson committed Sep 7, 2018
1 parent db16008 commit 45bc2a079882cb3786b767627f0ee60b2e3fb8c9
Showing with 5 additions and 3 deletions.
  1. +5 −3 python/plugins/processing/gui/BatchAlgorithmDialog.py
@@ -40,6 +40,7 @@
QgsProcessingOutputNumber,
QgsProcessingOutputString,
QgsProject,
QgsProcessingMultiStepFeedback,
Qgis,
QgsScopedProxyProgressTask)

@@ -117,6 +118,7 @@ def accept(self):
alg_parameters.append(parameters)

task = QgsScopedProxyProgressTask(self.tr('Batch Processing - {0}').format(self.algorithm().displayName()))
multi_feedback = QgsProcessingMultiStepFeedback(len(alg_parameters), feedback)

with OverrideCursor(Qt.WaitCursor):

@@ -139,6 +141,7 @@ def accept(self):
self.setProgressText(QCoreApplication.translate('BatchAlgorithmDialog', '\nProcessing algorithm {0}/{1}…').format(count + 1, len(alg_parameters)))
self.setInfo(self.tr('<b>Algorithm {0} starting&hellip;</b>').format(self.algorithm().displayName()), escapeHtml=False)
task.setProgress(100 * count / len(alg_parameters))
multi_feedback.setCurrentStep(count)

parameters = self.algorithm().preprocessParameters(parameters)

@@ -153,10 +156,9 @@ def accept(self):
context = dataobjects.createContext(feedback)

alg_start_time = time.time()
ret, results = execute(self.algorithm(), parameters, context, feedback)
ret, results = execute(self.algorithm(), parameters, context, multi_feedback)
if ret:
self.setInfo(QCoreApplication.translate('BatchAlgorithmDialog', 'Algorithm {0} correctly executed…').format(self.algorithm().displayName()), escapeHtml=False)
feedback.setProgress(100)
feedback.pushInfo(
self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - alg_start_time)))
feedback.pushInfo(self.tr('Results:'))
@@ -166,7 +168,7 @@ def accept(self):
else:
break

handleAlgorithmResults(self.algorithm(), context, feedback, False)
handleAlgorithmResults(self.algorithm(), context, multi_feedback, False)

feedback.pushInfo(self.tr('Batch execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
task = None

0 comments on commit 45bc2a0

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