geopython / pywps

PyWPS is an implementation of the Web Processing Service standard from the Open Geospatial Consortium. PyWPS is written in Python.
https://pywps.org
MIT License
178 stars 117 forks source link

Customize URL as a function of the data format #522

Closed huard closed 3 years ago

huard commented 4 years ago

Overview

This PR proposes a mechanism that customizes the URL of an output based on its data format. By default the standard outputurl is used, but if the data format (identified by the field of the FORMATS tuple) is included in the services section of the configuration, then this is substituted.

Related Issue / Discussion

Fixes #512

The use case for this is to run a THREDDS server or GeoServer alongside a PyWPS server, and serve some of the process outputs using dedicated services instead of a simple file url.

Additional Information

Contribution Agreement

(as per https://github.com/geopython/pywps/blob/master/CONTRIBUTING.rst#contributions-and-licensing)

huard commented 4 years ago

If this sounds about right, I'll update the documentation.

cehbrecht commented 4 years ago

With this PR we can configure different output urls depending on the mime-type (like WMS, OpenDAP, ...). The process does not need to worry about this. It uses the the pywps FORMATS for configuring the output url for a specific mime-type (like WMS130): https://github.com/geopython/pywps/blob/d05483d75e753b3cda303f5c0bb778a0f9465393/pywps/inout/formats/__init__.py#L18

@tomkralidis @jachym @ldesousa Are you happy with this approach?

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.3%) to 74.225% when pulling f80804c990db4586884757670c3d22bcf509d874 on huard:service_url into dd7db7bbe96a7516b24df175ad8c207f4de1d512 on geopython:master.

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.3%) to 74.225% when pulling 02f75a695dcc776b736248ac43ab42c76d6308d9 on huard:service_url into dd7db7bbe96a7516b24df175ad8c207f4de1d512 on geopython:master.

jachym commented 4 years ago

This looks cool, but could I ask you for adding some more descriptive example in the documatation, where you could describe the integration with GeoServer? E.g. in https://pywps.readthedocs.io/en/latest/external-tools.html ?

huard commented 4 years ago

I don't really know how it would work, because the url for WMS/WFS is not just a path, but a request. I'll need help on this one.

huard commented 4 years ago

From what I can quickly understand, adding a layer to GeoServer requires a call to the REST API, telling it in which workspace it should go, what is the default style, etc. The solution I propose in this PR is too basic for this. Saving to GeoServer would probably be done explicitly within the process handler:

url = store_geoserver(feature, workspace, **kwargs)
request.response['output'].url = url
jachym commented 4 years ago

ok, we have to work on the store_geoserver function, whatever it may be

from I have no more questions, we can merge

cehbrecht commented 4 years ago

@huard ok to merge?

huard commented 4 years ago

I'm concerned we will need to change the config to support the GeoServer use case. Do you want to mention in the docs that this feature should be considered experimental ?

To support @jachym use case with GeoServer, I can see two options:

  1. Have a store_geoserver function called explicitly inside the process handler. Developer would be responsible for the configuration.
  2. Have a GeoServerStorage class, that is used for certain output mime-types.

In the case of 2, the configuration would probably be like:

[storage]
DODS=thredds
WMS=geoserver
*=file [or s3]

[file]
host=
outputpath=

[geoserver]
host=
workspace=

[thredds]
host=
outputpath=
cehbrecht commented 4 years ago

I think I would prefer option 2 ...having a GeoServerStorage class. Could this be done in another PR?

huard commented 4 years ago

Yes, but then this PR should not be merged, as it will conflict.

jachym commented 4 years ago

I suggest, we leave the geoserver usace for now (if you are not desperately looking forward to implement it) and and make some ticket.

The GeoServer should use gsutil python module. I think that this truly leads to GeoServer storage class - because "all the data" would be then distributed via geoserver serivices

And in the future, MapServer would be nice too ;-)