Skip to content

Commit eaee80a

Browse files
committedSep 22, 2017
Better debugging for models by showing child algorithm parameters in the log
1 parent 6afe25e commit eaee80a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed
 

‎src/core/processing/models/qgsprocessingmodelalgorithm.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,16 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
256256

257257
QVariantMap childParams = parametersForChildAlgorithm( child, parameters, childResults, expContext );
258258
feedback->setProgressText( QObject::tr( "Running %1 [%2/%3]" ).arg( child.description() ).arg( executed.count() + 1 ).arg( toExecute.count() ) );
259-
//feedback->pushDebugInfo( "Parameters: " + ', '.join( [str( p ).strip() +
260-
// '=' + str( p.value ) for p in alg.algorithm.parameters] ) )
259+
260+
QStringList params;
261+
for ( auto childParamIt = childParams.constBegin(); childParamIt != childParams.constEnd(); ++childParamIt )
262+
{
263+
params << QStringLiteral( "%1: %2" ).arg( childParamIt.key(),
264+
child.algorithm()->parameterDefinition( childParamIt.key() )->valueAsPythonString( childParamIt.value(), context ) );
265+
}
266+
267+
feedback->pushInfo( QObject::tr( "Input Parameters:" ) );
268+
feedback->pushCommandInfo( QStringLiteral( "{ %1 }" ).arg( params.join( QStringLiteral( ", " ) ) ) );
261269

262270
QTime childTime;
263271
childTime.start();
@@ -285,7 +293,7 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
285293

286294
executed.insert( childId );
287295
modelFeedback.setCurrentStep( executed.count() );
288-
feedback->pushDebugInfo( QObject::tr( "OK. Execution took %1 s (%2 outputs)." ).arg( childTime.elapsed() / 1000.0 ).arg( results.count() ) );
296+
feedback->pushInfo( QObject::tr( "OK. Execution took %1 s (%2 outputs)." ).arg( childTime.elapsed() / 1000.0 ).arg( results.count() ) );
289297
}
290298

291299
if ( feedback && feedback->isCanceled() )

0 commit comments

Comments
 (0)
Please sign in to comment.