You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using model designer to export a model as a python script, if there is any algorithm that have a multi-line comment in Algorithm -> Comment the script won't work because the exporter fails to properly catch newline in the comment and will only commented out the first line only. This will throw a python SyntaxError.
Python script error:
An error has occurred while executing Python code:
SyntaxError: invalid syntax
Traceback (most recent call last):
File "C:\PROGRA~1/QGIS32~1.11/apps/qgis-ltr/./python/plugins\processing\script\ScriptAlgorithmProvider.py", line 121, in loadAlgorithms
alg = ScriptUtils.loadAlgorithm(moduleName, filePath)
File "C:\PROGRA~1/QGIS32~1.11/apps/qgis-ltr/./python/plugins\processing\script\ScriptUtils.py", line 67, in loadAlgorithm
spec.loader.exec_module(module)
File "", line 851, in exec_module
File "", line 988, in get_code
File "", line 918, in source_to_code
File "", line 228, in _call_with_frames_removed
File "C:\Users\Asus\AppData\Roaming\QGIS\QGIS3\profiles\default\processing\scripts\EXPORTED_MODEL.py", line 32
Uncommented newline
^
SyntaxError: invalid syntax
Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]
QGIS version: 3.22.11-Białowieża Białowieża, 106d33d7
Steps to reproduce the issue
Create a simple model with one input and one algorithm
Add a multi-line comment in the algorithm --> comment tab
Export the model as a python script
Try to run the exported script
def processAlgorithm(self, parameters, context, model_feedback):
# Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the
# overall progress through the model
feedback = QgsProcessingMultiStepFeedback(1, model_feedback)
results = {}
outputs = {}
# Points along geometry
# This is a comment in line one
This is a comment in line two
alg_params = {
'DISTANCE': 1,
'END_OFFSET': 0,
'INPUT': parameters['test'],
'START_OFFSET': 0,
'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT
}
This behavior also occurs in model input comment
self.addParameter(QgsProcessingParameterField('omit', 'OMITb', type=QgsProcessingParameterField.Any, parentLayerParameterName='before', allowMultiple=False, defaultValue=None))
# This is a comment in line one
This is a comment in line two
Versions
QGIS version | 3.22.11-Białowieża | QGIS code revision | 106d33d7
-- | -- | -- | --
Qt version | 5.15.3
Python version | 3.9.5
GDAL/OGR version | 3.5.1
PROJ version | 9.1.0
EPSG Registry database version | v10.074 (2022-08-01)
GEOS version | 3.10.3-CAPI-1.16.1
SQLite version | 3.38.1
PDAL version | 2.4.3
PostgreSQL client version | 14.3
SpatiaLite version | 5.0.1
QWT version | 6.1.6
QScintilla2 version | 2.13.1
OS version | Windows 10 Version 2009
| | |
Active Python plugins
autoSaver | 2.6
batchvectorlayersaver | 0.9
CalculateGeometry | 0.6.8
FreehandRasterGeoreferencer | 0.8.3
latlontools | 3.6.6
profiletool | 4.2.2
qgsAzimuth | 0.9.15
QuickOSM | 2.1.1
quick_map_services | 0.19.29
SRTM-Downloader | 3.1.17
db_manager | 0.1.20
MetaSearch | 0.3.5
processing | 2.12.99
sagaprovider | 2.12.99
Supported QGIS version
I'm running a supported QGIS version according to the roadmap.
New profile
I tried with a new QGIS profile
Additional context
The script can be fixed by manually finding uncommented line in the exported script.
The text was updated successfully, but these errors were encountered:
What is the bug or the crash?
When using model designer to export a model as a python script, if there is any algorithm that have a multi-line comment in
Algorithm -> Comment
the script won't work because the exporter fails to properly catch newline in the comment and will only commented out the first line only. This will throw a python SyntaxError.Python script error:
Steps to reproduce the issue
This behavior also occurs in model input comment
Versions
Supported QGIS version
New profile
Additional context
The script can be fixed by manually finding uncommented line in the exported script.
The text was updated successfully, but these errors were encountered: