Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named algorithm outputs in modeler fail when used as inputs #27200

Closed
qgib opened this issue Jul 9, 2018 · 2 comments
Closed

Named algorithm outputs in modeler fail when used as inputs #27200

qgib opened this issue Jul 9, 2018 · 2 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore

Comments

@qgib
Copy link
Contributor

qgib commented Jul 9, 2018

Author Name: Rudi von Staden (@rudivs)
Original Redmine Issue: 19372
Affected QGIS version: 3.2
Redmine category:processing/modeller


Using the modeler in QGIS 3.2, if you give a name to the output of an algorithm, you can't use that output as input for a subsequent algorithm. Trying to do so results in a processing error (Could not load source layer for INPUT: invalid value). I have attached a test project with some data and a model to demonstrate the issue. Included is a folder with an equivalent project in QGIS 2.18 showing that the same model worked in previous versions.

The model runs two parallel processes which are identical (polygonize raster then extract by attribute) except the second names the output of the polygonize step before using it in the extract step. I am fairly sure that this is not an issue with the test algorithms used here, but more broadly with the mapping of input and output parameters in models. You can see in the model log below that the first 'extract by attribute' algorithm was able to find the input file (standard named OUTPUT.shp) but the second time the algorithm is executed it has an empty INPUT parameter. This is probably because the output of the previous step results in a file named gdal_polygonize_2_DEM_vector.shp, not OUTPUT.shp as usual.

I am not sure where the mapping of output and input names happens in the processing code (and whether it's executed in c++ or Python). If it's in Python I'd be happy to look into it if someone can tell me which class or file to start the investigation.

Processing algorithm…
Algorithm 'named_output_used_as_input' starting…
Input parameters:
{ 'dem' : 'C:/Users/rudi_000/Dropbox/GIS/shared/named_output_used_as_input_test/dem.tif', 'gdal:polygonize_2:DEM_vector' : 'C:/Users/rudi_000/AppData/Local/Temp/processing_37290c9f65694832953690d6bd83266d/bfa5cb1aca8a4c8b8a9b7da1b85da366/gdal_polygonize_2_DEM_vector.shp', 'native:extractbyattribute_1:Output 1' : 'memory:', 'native:extractbyattribute_2:Output 2 (named output)' : 'memory:' }

Prepare algorithm: gdal:polygonize_1
Running Polygonize 1 [1/4]
Input Parameters:
{ BAND: 1, EIGHT_CONNECTEDNESS: False, FIELD: 'DN', INPUT: 'C:/Users/rudi_000/Dropbox/GIS/shared/named_output_used_as_input_test/dem.tif', OUTPUT: 'C:/Users/rudi_000/AppData/Local/Temp/processing_37290c9f65694832953690d6bd83266d/e715a21a7ae64c79a5b864dc72c5a6b1/OUTPUT.shp' }
GDAL command:
cmd.exe /C gdal_polygonize.bat C:/Users/rudi_000/Dropbox/GIS/shared/named_output_used_as_input_test/dem.tif C:/Users/rudi_000/AppData/Local/Temp/processing_37290c9f65694832953690d6bd83266d/e715a21a7ae64c79a5b864dc72c5a6b1/OUTPUT.shp -b 1 -f "ESRI Shapefile" None DN
GDAL command output:
0...10...20...30...40...50...60...70...80...90...Creating output C:/Users/rudi_000/AppData/Local/Temp/processing_37290c9f65694832953690d6bd83266d/e715a21a7ae64c79a5b864dc72c5a6b1/OUTPUT.shp of format ESRI Shapefile.

100 - done.

OK. Execution took 29.186 s (1 outputs).
Prepare algorithm: native:extractbyattribute_1
Running Extract by attribute [2/4]
Input Parameters:
{ FIELD: 'DN', INPUT: 'C:/Users/rudi_000/AppData/Local/Temp/processing_37290c9f65694832953690d6bd83266d/e715a21a7ae64c79a5b864dc72c5a6b1/OUTPUT.shp', OPERATOR: 0, OUTPUT: 'memory:', VALUE: '1' }
OK. Execution took 0.116 s (1 outputs).
Prepare algorithm: gdal:polygonize_2
Running Polygonize 2 (named output) [3/4]
Input Parameters:
{ BAND: 1, EIGHT_CONNECTEDNESS: False, FIELD: 'DN', INPUT: 'C:/Users/rudi_000/Dropbox/GIS/shared/named_output_used_as_input_test/dem.tif', OUTPUT: 'C:/Users/rudi_000/AppData/Local/Temp/processing_37290c9f65694832953690d6bd83266d/bfa5cb1aca8a4c8b8a9b7da1b85da366/gdal_polygonize_2_DEM_vector.shp' }
GDAL command:
cmd.exe /C gdal_polygonize.bat C:/Users/rudi_000/Dropbox/GIS/shared/named_output_used_as_input_test/dem.tif C:/Users/rudi_000/AppData/Local/Temp/processing_37290c9f65694832953690d6bd83266d/bfa5cb1aca8a4c8b8a9b7da1b85da366/gdal_polygonize_2_DEM_vector.shp -b 1 -f "ESRI Shapefile" None DN
GDAL command output:
0...10...20...30...40...50...60...70...80...90...Creating output C:/Users/rudi_000/AppData/Local/Temp/processing_37290c9f65694832953690d6bd83266d/bfa5cb1aca8a4c8b8a9b7da1b85da366/gdal_polygonize_2_DEM_vector.shp of format ESRI Shapefile.

100 - done.

OK. Execution took 29.425 s (1 outputs).
Prepare algorithm: native:extractbyattribute_2
Running Extract by attribute [4/4]
Input Parameters:
{ FIELD: 'DN', INPUT: '', OPERATOR: 0, OUTPUT: 'memory:', VALUE: '1' }
Could not load source layer for INPUT: invalid value
Error encountered while running Extract by attribute
Error encountered while running Extract by attribute
Execution failed after 59.70 seconds

Loading resulting layers
Algorithm 'named_output_used_as_input' finished

@qgib
Copy link
Contributor Author

qgib commented Jul 10, 2018

Author Name: Nyall Dawson (@nyalldawson)


  • status_id was changed from Open to In Progress

@qgib
Copy link
Contributor Author

qgib commented Jul 12, 2018

Author Name: Nyall Dawson (@nyalldawson)


Applied in changeset 41825ca.


  • done_ratio was changed from 0 to 100
  • status_id was changed from In Progress to Closed

@qgib qgib closed this as completed Jul 12, 2018
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

No branches or pull requests

1 participant