bird-house / finch

A Web Processing Service for Climate Indicators
https://finch.readthedocs.io/en/latest/
Apache License 2.0
12 stars 5 forks source link

Use AllowedValue to constrain indicator arguments to the positive domain #124

Open huard opened 4 years ago

huard commented 4 years ago

Description

For example, see arguments in

huard commented 4 years ago

@dbyrns In the climatedata.ca frontend, the fact some parameters could be given negative values even if it makes no sense was flagged as a potential issue. I'm wondering if this is something that should be fixed upstream, either in Finch or even in xclim. Thoughts ? PyWPS has an AllowedValue class that we could use, but ideally the Finch wrapper would take instructions from xclim.

dbyrns commented 4 years ago

In Finch, the AllowedValue could indeed specify a range with a minimum value of 0. Since Finch create the pywps inputs by parsing attributes of xclim function (https://github.com/bird-house/finch/blob/5a8beba34f608a49787d265ac9da8bb36f1e5be5/finch/processes/wps_base.py#L112) we could build on the naming convention or explore the docstring proposition...

dbyrns commented 4 years ago

I cannot set an assignee, but @MatProv could look at this.

huard commented 4 years ago

See https://github.com/Ouranosinc/xclim/issues/364#issuecomment-617973075 for ideas on how to specify those constraints right from xclim, and then propagate them downstream. Comment and suggestions welcome.

aulemahal commented 2 years ago

I'm doing a survey of all those stale issues.

Here, the last comments seem to point to xclim's kind mechanism on indicator arguments to obtain information about the allowed values. Currently the (stable) mechanism in xclim does not provide much information about this. Example : it has the "Number" kind, which doesn't tell anything about the allowed range. Moreover, quantities (value + unit) are passed as strings and only parsed within xclim : pywps' AllowedValue can't do much here.

I'm not convinced xclim needs a strict input validator, so we could do that here, but it would need something more complex than filling AllowedValue. For example:

if kind is NUMBER and name == ''window":
    # ensure positive integer
elif kind is QUANTITY and units.diemsionality == "[precipitation]":
    # ensure positive
# etc...