Bug report #18605

Field Mapper parameters cannot have parent layer set in models

Added by gcarrillo - almost 6 years ago. Updated almost 5 years ago.

Status:Open
Priority:Normal
Assignee:Victor Olaya
Category:Processing/Modeller
Affected QGIS version:3.7(master) Regression?:No
Operating System:GNU/Linux (Linux Mint based on Ubuntu Xenial) Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:26493

Description

A model using Refactor Fields algorithm is expected to have two inputs:

1) Input Layer
2) Fields Mapper

When running such model and setting an input layer, the Source Expression in the Fields Mapper widget never gets a layer set. Therefore, users cannot choose among input layer fields nor use "Fields and Values" section in the Expression builder dialog.

Explanatory GIF: http://downloads.tuxfamily.org/tuxgis/tmp/refactor_fields_expression_layer.gif

model_etl_ladm_col.model3 - Working model (5.33 KB) gcarrillo -, 2018-04-01 05:07 AM

model_etl_ladm_col_.model3 - Non-working model (5.33 KB) gcarrillo -, 2018-04-01 05:07 AM

History

#1 Updated by gcarrillo - almost 6 years ago

I've discovered a few strange things there:

1) Modeler seems to force parameter names to lowercase, which doesn't seem the case of other Processing algorithms.

2) In the FieldsMappingWidgetWrapper (https://github.com/qgis/QGIS/blob/3c7f7454245d63ecd04f092a5c698becf1a233dc/python/plugins/processing/algs/qgis/ui/FieldsMappingPanel.py#L482) this comparison is made:

wrapper.param.name() == self.param.parentLayerParameter()

A quick check of my model parameters, like:

alg = QgsApplication.processingRegistry().algorithmById("model:mymodel")
for p in alg.parameterDefinitions():
    print("parameter name", p.name())
    if type(p) == processing.algs.qgis.FieldsMapper.FieldsMapper.ParameterFieldsMapping:
        print("...parent layer paremeter",p.parentLayerParameter())

allows me to know that my input parameter and the parentLayerParameter will never match because my model parameters are in lowercase, whereas the RefactorFields input is uppercase (it is 'INPUT').

3) If I edit the .model3 file and give my parameter the name 'INPUT' (uppercase), the whole issue is gone. The problem is saving in the Processing modeler.

I attach two models:

+ A working model (model_etl_ladm_col.model3)
+ A non-working model (model_etl_ladm_col_.model3)

#2 Updated by Nyall Dawson almost 6 years ago

  • Subject changed from Malfunction using Refactor Fields algorithm in Processing models to Field Mapper parameters cannot have parent layer set in models

Root cause is that when using a field mapper parameter in model, there's currently no way to set the associated parent layer parameter

#3 Updated by Giovanni Manghi about 5 years ago

  • Status changed from Open to Feedback

Please check if this issue is still valid on QGIS 3.4.5 or 3.6.

#4 Updated by gcarrillo - about 5 years ago

Giovanni Manghi wrote:

Please check if this issue is still valid on QGIS 3.4.5 or 3.6.

I confirm this is still happening in current master (v3.7).

#5 Updated by Giovanni Manghi almost 5 years ago

  • Affected QGIS version changed from master to 3.7(master)
  • Status changed from Feedback to Open

Also available in: Atom PDF