-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
processing.runAndLoadResults does not load results #40
Comments
Contexts are somewhat different about how results are handled in Qgis Desktop and py-qgis-wps: In Qgis desktop, output results are automatically added in to the current Project context and I guess that that the expression used in your second calculation in your algorithm refers to to the output layer of calculation 1. In py-qgis-wps, the source project is never modified implicitely for obvious reason that a given process should be idempotent. Output layers must be handled explicitely (Output layer parameters are added to a destination project different from the source project). So I suggest that that you explicitely pass the output of the first algorithm as input of the second one, instead of assuming that the first output is appended implicitely to the source project - which is never the case in py-qgis-wps. |
Thank you for your answer. Unfortunately So I have 2 options:
|
The destination project is the one that is available in the def processAlgorithm(self, parameters, context, feedback):
res = processing.runAndLoadResults(
"qgis:rastercalculator",
{
'EXPRESSION': '1',
'LAYERS': None,
'CELLSIZE': 10,
'EXTENT': '67740.870400000,79959.890400000,341924.860400000,360502.590400000 [EPSG:31255]',
'CRS': QgsCoordinateReferenceSystem('EPSG:31255'),
'OUTPUT': "test.tiff"}, context=context, feedback=feedback)
return {'OUTPUT': res['OUTPUT']} The created layer should have been added to the destination project, right? The log shows this:
where but when I open Am I doing something wrong? |
I guess because the destination project is not correct: you may check the destination project with the following snippet
if |
EDIT: If I manually add the layer to |
My bad: this is because the project has still not beeing assigned to a file, sorry. So it is not suprising that
This is what is supposed to happen when it says: |
I checked if the projects match with this code: for layername, details in context.layersToLoadOnCompletion().items():
feedback.pushDebugInfo(f"{layername} project: {details.project is context.destination_project}") the output is EDIT: for layername, details in context.layersToLoadOnCompletion().items():
feedback.pushDebugInfo(f"{layername} project: {details.project is QgsProject.instance()}") and it printed |
I have recently started using QGIS WPS. I am using the docker image 3liz/qgis-wps:3.30. For testing I wrote a very simple algorithm with no INPUT or OUTPUT:
it simply creates a raster layer and uses it in the next step to create a second raster layer. It works absolutely fine when I run it in QGIS Desktop, but when I run it in through WPS I get the following log:
I investigated a little further and the problem is that
runAndLoadResults
does not load the output layer. When I instead use the following code for step 1 it works fine:Since it works in QGIS Desktop but not in WPS I assume this might be a bug.
I use the following docker-compose.yml:
Complete algorithm: https://pastebin.com/8EcRwdVi
The text was updated successfully, but these errors were encountered: