-
Notifications
You must be signed in to change notification settings - Fork 117
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
How to use OpenDAP with PyWPS? #152
Comments
Hi Carsten, PyWPS is trying to handle the data inputs for you - and make sure, you are downloading right data, not too big, because you are operating with untrusted source. We try not to download data bigger than the configuration value (server -> maxsingleinputsize) and then validation can be applied (pywps.inout.formats.Format -> validate and mode attributes). Having said that, I see your needs and it makes sense to me to address them. I can also see, having services around, like FME, it makes sense enable usage of such services and leave the input data handling and validating to them - to trusted 3rd party services. Well, I think, we would need some complex approach to this topic, do you see any possible solution in |
@jachym |
We talked about this at the OGC coding-sprint in Bonn. I will make a small modification of the PyWPS 4.x code to make it possible to provide a netCDF file and a OpenDAP URL with the same |
See ticket bird-house/flyingpigeon#231. It references a code snippet to check if a URL is OpenDAP: Maybe this code example could be used for a PyWPS input validator. |
@cehbrecht That looks a very reasonable approach, as discussed in Bonn. |
@huard PR #387 introduces the Currently the implementation (in the PR) uses the The reasoning for this is to have the same
Currently I have to use:
|
You're right. Will think about it. |
I've thought about this, and here is the problem I see. The convention I've used is that accessing url does not trigger a download, it's just a link. So if for certain url we download the file locally and we don't for other types of files, I think we're creating confusion. Same thing for file, the idea is that accessing file creates a local copy of the link provided by the request. Accessing the file property of an opendap ComplexInput downloads the full file. My guess is that it would be clearer to write something like the following
Another issue is that if an input has more than one supported format (netCDF and DODS), and the user does not specify the mimetype, pywps picks the first one by default. I don't know how to pass the mimetype using key-value pairs, is that even possible? |
When we enable validation for inputs the NetCDF/OpenDAP validator (bird-house#1) can check the mimetype of the input data. The WPS protocol allows it also to set explicitly the mimetype ... but it is optional and nothing we can rely on (relevant for the validator only?): But relying on pywps to figure out the right mimetype is error-prone. |
Well, I thought the following would work:
But the
Maybe we can add a util method:
|
... follow up. The util method makes only sense when pywps can guess the right mimetype. Otherwise we need separate input parameters for netcdf and opendap, like already in |
Support for file URLs is something we could ask upstream libraries to support (netCDF4, xarray), but it's not a short term fix.
|
That, in the case the mimetype is unknown. |
That might work ... I can try it with |
I have added an I have done it different ... using |
Looks good. Note that the next PR will include a new FORMATS.DODS for open dap mimetypes. I'm just waiting for the UrlHandler PR to go in before submitting it. |
Just give me a "go" on the url_handler PR and I can pull it in. |
Hum, your nc_resource won't work for file:/// schema... |
Go. I've added a few tests. Nothing broke. |
It does not work on Python 2.7 due to import issue in PR #387:
|
@cehbrecht I think this can be closed. |
Initial support is integrated in pywps now. |
i'm using PyWPS for processing of climate data. A major data format used here is NetCDF. In PyWPS one can use a complex type with mime-type
application/x-netcdf
to define input and output parameters for NetCDF files.Another important way to access NetCDF files is with OpenDAP. A data service to access parts of the remote NetCDF file. The OGC WPS Best Practise paper recommends the mime-type
application/x-ogc‐dods
for OpenDAP. If one would provide an OpenDAP url in a complex-type, PyWPS would try downloading it ... this is not the right behaviour, it should just pass it to the process. I could add a patch to fix this behaviour for OpenDAP mime-types.A workaround would be to use a string parameter for the OpenDAP url. But then you loose the descriptive mime-type (which is used by generic wps clients).
The Python NetCDF4 library can handle both NetCDF files and OpenDAP urls with the same initialisation code (
Dataset(file_or_url)
), so for a process it would not be necessary to have separate input parameters for OpenDAP and NetCDF.Any recommendations on this topic?
Cheers,
Carsten
The text was updated successfully, but these errors were encountered: