qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.66k stars 3.01k forks source link

Model Designer - Python Converter not generating unique keys #54150

Open kauevestena opened 1 year ago

kauevestena commented 1 year ago

What is the bug or the crash?

The converter cannot generate unique dictionary keys for the "outputs" dictionary.

I came across this problem when I was translating more complicated models, but this simpler one reproduces the issue:

image

Look at the relevant part of the Python converted code:

image

so duplicate keys, in this way, running the algorithm using the model builder returns this result:

image

and using the Python converted version, holds this one:

image

since this will overwrite the value of the key in the dictionary.

Steps to reproduce the issue

I've made this sample available in this gist:

https://gist.github.com/kauevestena/8094a17abf511eb7cea4493db431dfa8

1) Save both files with their original names

2) add the .model3 version: image

3) add the .py version: image

4) run both, et voilá

(processing toolbox is activated on View > Panels > Processing Toolbox )

Versions

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

QGIS version | 3.32.1-Lima | QGIS code revision | 4a078ecf63 -- | -- | -- | -- Qt version | 5.15.3 Python version | 3.10.6 GDAL/OGR version | 3.4.1 PROJ version | 8.2.1 EPSG Registry database version | v10.041 (2021-12-03) GEOS version | 3.10.2-CAPI-1.16.0 SQLite version | 3.37.2 PDAL version | 2.3.0 PostgreSQL client version | 14.8 (Ubuntu 14.8-0ubuntu0.22.04.1) SpatiaLite version | 5.0.1 QWT version | 6.1.4 QScintilla2 version | 2.11.6 OS version | Ubuntu 22.04.2 LTS   |   |   |   Active Python plugins Mergin | 2023.2 QuickOSM | 2.2.2 pluginbuilder3 | 3.2.1 plugin_reloader | 0.9.3 osm2topomap | 0.1 osm_sidewalkreator | 1.1 quick_map_services | 0.19.33 grassprovider | 2.12.99 MetaSearch | 0.3.6 processing | 2.12.99 db_manager | 0.1.20 QGIS version 3.32.1-Lima QGIS code revision [4a078ecf63](https://github.com/qgis/QGIS/commit/4a078ecf63) Qt version 5.15.3 Python version 3.10.6 GDAL/OGR version 3.4.1 PROJ version 8.2.1 EPSG Registry database version v10.041 (2021-12-03) GEOS version 3.10.2-CAPI-1.16.0 SQLite version 3.37.2 PDAL version 2.3.0 PostgreSQL client version 14.8 (Ubuntu 14.8-0ubuntu0.22.04.1) SpatiaLite version 5.0.1 QWT version 6.1.4 QScintilla2 version 2.11.6 OS version Ubuntu 22.04.2 LTS Active Python plugins Mergin 2023.2 QuickOSM 2.2.2 pluginbuilder3 3.2.1 plugin_reloader 0.9.3 osm2topomap 0.1 osm_sidewalkreator 1.1 quick_map_services 0.19.33 grassprovider 2.12.99 MetaSearch 0.3.6 processing 2.12.99 db_manager 0.1.20 ### Supported QGIS version - [X] I'm running a supported QGIS version according to [the roadmap](https://www.qgis.org/en/site/getinvolved/development/roadmap.html#release-schedule). ### New profile - [X] I tried with a new [QGIS profile](https://docs.qgis.org/latest/en/docs/user_manual/introduction/qgis_configuration.html#working-with-user-profiles) ### Additional context It has been tested on more than one machine. Apparently, the part of the code that where this functionality could be implemented is: https://github.com/qgis/QGIS/edit/master/src/core/processing/models/qgsprocessingmodelalgorithm.cpp#L627
pathmapper commented 1 year ago

Hi @kauevestena, thanks for reporting, looks like a duplicate of https://github.com/qgis/QGIS/issues/50089.

BTW, no need for exclamation marks in the issue title.

kauevestena commented 1 year ago

I didn't realize, but this one is more straightforward,

Sorry, bad habit!! Now there are no more exclamations there!

pathmapper commented 1 year ago

this one is more straightforward

Right, I've closed the other one.