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

The native:meshexporttimeseries algorithm breaks when run in a standalone script #57986

Open
2 tasks done
kylefelipe opened this issue Jul 4, 2024 · 6 comments
Open
2 tasks done
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms PyQGIS Related to the PyQGIS API

Comments

@kylefelipe
Copy link

What is the bug or the crash?

Traceback (most recent call last):
File "/home/kylefelipe/terraq_repo/tarefa_qgis_netcdf/script_luiz.py", line 119, in
processing.run("native:meshexporttimeseries", configs)
File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 109, in run
return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 215, in runAlgorithm
raise QgsProcessingException(msg)
_core.QgsProcessingException: There were errors executing the algorithm.

Steps to reproduce the issue

Download this script.py from gist click here
Download the example files in the same folder as the script Google Drive
Run the script from the terminal, or OSGEO Shell.
Linux example:

python3 script.py

Versions

QGIS version 3.34.8-Prizren QGIS code revision 9164233
Qt version 5.15.3
Python version 3.10.12
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.12 (Ubuntu 14.12-0ubuntu0.22.04.1)
SpatiaLite version 5.0.1
QWT version 6.1.4
QScintilla2 version 2.11.6
OS version Ubuntu 22.04.4 LTS
       
Active Python plugins
quick_map_services 0.19.34
MetaSearch 0.3.6
processing 2.12.99
grassprovider 2.12.99
db_manager 0.1.20

QGIS version
3.34.8-Prizren
QGIS code revision
91642333b10
Qt version
5.15.3
Python version
3.10.12
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.12 (Ubuntu 14.12-0ubuntu0.22.04.1)
SpatiaLite version
5.0.1
QWT version
6.1.4
QScintilla2 version
2.11.6
OS version
Ubuntu 22.04.4 LTS

Active Python plugins
quick_map_services
0.19.34
MetaSearch
0.3.6
processing
2.12.99
grassprovider
2.12.99
db_manager
0.1.20

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

Runing meshexporttimeseries from GUI works like a charm.
STEPS:

Add the .nc file as Mesh layer to project
Set mesh projection to ESPG:4326
Add the gpkg as vector layer to project
Go to Toolbox> Double click on Export time series values from points of a mesh dataset
Input mesh layere > Choose mesh layer above
Data set groups > Click on ... then Select in available dataset groups then select all > ok
Ending time > choose the last one (press end on keyboard)
Points for data export > Choose pont layer
Digits count for coordinates > 8
Digits count for dataset value > 8
exported data csv file > choose path and file name
click run...

@kylefelipe kylefelipe added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jul 4, 2024
@agiudiceandrea agiudiceandrea added PyQGIS Related to the PyQGIS API Processing Relating to QGIS Processing framework or individual Processing algorithms labels Jul 4, 2024
@agiudiceandrea
Copy link
Member

agiudiceandrea commented Jul 4, 2024

@kylefelipe, thanks for reporting. Does the output of the commands

from qgis.core import QgsProviderRegistry
print(QgsProviderRegistry.instance().providerList())

added just before the mesh_layer = QgsMeshLayer(mesh_path, "mesh", "mdal") contain the mdal provider name?
Does the output of print(mesh_layer) added just after mesh_layer = QgsMeshLayer(mesh_path, "mesh", "mdal") states that it is a valid layer?

In order to avoid the error

  File "C:\OSGeo4W_V2_8/apps/qgis/python/plugins\processing\core\Processing.py", line 231, in runAlgorithm
    raise QgsProcessingException(msg)
_core.QgsProcessingException: There were errors executing the algorithm.

you need to put the QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms()) after the Processing.initialize() line, not before. Anyway, QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms()) is not needed.

@agiudiceandrea agiudiceandrea added the Feedback Waiting on the submitter for answers label Jul 4, 2024
@kylefelipe
Copy link
Author

Hi @agiudiceandrea, thx for helping me!

print(QgsProviderRegistry.instance().providerList())
added just before the mesh_layer = QgsMeshLayer(mesh_path, "mesh", "mdal") contain the mdal provider name?

R: No, just show these names
['arcgisvectortileservice', 'cesiumtiles', 'copc', 'ept', 'gdal', 'mbtilesvectortiles', 'memory', 'mesh_memory', 'ogr', 'tiledscene', 'vectortile', 'vpc', 'vtpkvectortiles', 'xyzvectortiles']

Does the output of print(mesh_layer) added just after mesh_layer = QgsMeshLayer(mesh_path, "mesh", "mdal") states that it is a valid layer?

R) No, it shows that is an invalid layer

you need to put the QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms()) after the Processing.initialize() line, not before. Anyway, QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms()) is not needed.

R) Thx.

I am updating the gist with new code...
And its still issuing (...) There where errors executing the algorithm

Copy link

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale".
If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue.
In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue.
If there is no further activity on this issue, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jul 24, 2024
@agiudiceandrea agiudiceandrea removed Feedback Waiting on the submitter for answers stale Uh oh! Seems this work is abandoned, and the PR is about to close. labels Jul 24, 2024
@agiudiceandrea
Copy link
Member

I am updating the gist with new code...

Does the new code make QgsProviderRegistry.instance().providerList() contain the mdal provider name and mesh_layer be a valid mesh layer? What is the full error message?

@kylefelipe
Copy link
Author

kylefelipe commented Aug 1, 2024

@agiudiceandrea

I am updating the gist with new code...

Does the new code make QgsProviderRegistry.instance().providerList() contain the mdal provider name and mesh_layer be a valid mesh layer? What is the full error message?

No...

Full error:

Provider list ['arcgisvectortileservice', 'cesiumtiles', 'copc', 'ept', 'gdal', 'mbtilesvectortiles', 'memory', 'mesh_memory', 'ogr', 'tiledscene', 'vectortile', 'vpc', 'vtpkvectortiles', 'xyzvectortiles']
Layer is valid: False
<QgsMeshLayer: 'mesh' (Invalid)>
Traceback (most recent call last):
  File "/home/kylefelipe/terraq_repo/tarefa_qgis_netcdf/using_pyqgis.py", line 72, in <module>
    processing.run("native:meshexporttimeseries", configs)
  File "/usr/share/qgis/python/plugins/processing/tools/general.py", line 109, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 215, in runAlgorithm
    raise QgsProcessingException(msg)
_core.QgsProcessingException: There were errors executing the algorithm.

@abreufilho
Copy link

Any updates on that? Im running into the same issue.

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! Processing Relating to QGIS Processing framework or individual Processing algorithms PyQGIS Related to the PyQGIS API
Projects
None yet
Development

No branches or pull requests

3 participants