[PyWPS-dev] Question about process inputs

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PyWPS-dev] Question about process inputs

Suzana Barreto
Hi All,

I am in the process of testing a process I created using PyWPS 4.  I have found an odd issue with the LiteralInputs for my process.  So for example, my process takes an input parameter (stats) where I have a max_occurs=9 which should allow for any number of strings detailing the statistics I would like calculated for a given input file. When I issue a request with a number of values ('sum', 'median', 'std') for that particular parameter, my response contains the result for only 1 of the statistics for that parameter.  I traced the issue to service.py (create_literal_inputs), line 216 where a deque is created using the LiteralInput's max_occurs parameter to limit the size.  Unfortunately, it appears that this attribute is always 1.  When I do a describeProcess request, I notice that the max_occurs is also equal to 1 and this happens regardless of whatever value I change the max_occurs to on that or any other LiteralInputs for my process.  So my question is, has anyone come across this issue?  Am I doing something wrong?  Below is the code showing how I have defined the inputs.

class BasicZonalStats(Process):
def __init__(self):
inputs = [ComplexInput('aoi_ndvi','Raster ndvi',
supported_formats=[Format('image/tiff'), Format('application/x-ogc-wcs')],
min_occurs=1, max_occurs=1, mode=MODE.NONE),
LiteralInput('band','the band to calculate stats for', data_type='integer', min_occurs=1, max_occurs=1,
mode=MODE.SIMPLE),
LiteralInput('stats', 'Statistics to calculate', data_type='string', min_occurs=0, max_occurs=9,
allowed_values=('sum', 'std', 'median', 'majority', 'minority', 'unique', 'range',
'nodata', 'nan'), mode=MODE.SIMPLE),
LiteralInput('nodata','Nodata value', data_type='integer',mode=MODE.SIMPLE),
ComplexInput('zones', 'Vector polygons to calculate stats on.',
supported_formats=[Format('application/json')],
min_occurs=1, max_occurs=1, mode=MODE.NONE)

]
outputs = [ComplexOutput('zonal_stats', 'Attribute Table',
supported_formats=[Format('application/json')],
)]

super(BasicZonalStats, self).__init__(
self._handler,
identifier='zonal',
version='0.1',
title="Basic Zonal Statistics using Rasterstats",
abstract="This is a naive and basic WPS, it assumes that both vector and raster inputs are in the same"
"projection and as such does not do any error checking. This will be fixed at a later stage so f"
"or now please ensure that the inputs are in the same projection.",
profile='',
inputs=inputs,
outputs=outputs,
store_supported=True,
status_supported=True
)
Any help with this would be much appreciated. 
Thanks,
Suzana
--

Dr Suzana Barreto
Software Analyst
Environment Systems

Tel: <a style="color:rgb(17,85,204)" href="tel:%2B44%20%280%29%201970%20626688" value="+441970626688" target="_blank">+44 (0) 1970 626688
www.envsys.co.uk

The information contained in this e-mail is intended only for the use of the person(s) to whom it is addressed and may contain confidential or privileged information. If you have received this e-mail in error please contact the sender and delete the material without copying, distributing or disclosing the content. All reasonable precautions have been taken to ensure that this e-mail is free from any virus, however, the recipient should verify this to be the case. Please 'think before you print'


_______________________________________________
pywps-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pywps-dev
Reply | Threaded
Open this post in threaded view
|

Re: Question about process inputs

Suzana Barreto
Hi All,

I have found the bug which is in basic.py class LiteralInput, when it initialises BasicIO, it sets the min_occurs, max_occurs to 1 instead of using the passed in parameter.
Do I need to fix this in the code base, following the given procedures of course? 

Thanks,
Suzana


On Tue, 6 Nov 2018 at 15:09, Suzana Barreto <[hidden email]> wrote:
Hi All,

I am in the process of testing a process I created using PyWPS 4.  I have found an odd issue with the LiteralInputs for my process.  So for example, my process takes an input parameter (stats) where I have a max_occurs=9 which should allow for any number of strings detailing the statistics I would like calculated for a given input file. When I issue a request with a number of values ('sum', 'median', 'std') for that particular parameter, my response contains the result for only 1 of the statistics for that parameter.  I traced the issue to service.py (create_literal_inputs), line 216 where a deque is created using the LiteralInput's max_occurs parameter to limit the size.  Unfortunately, it appears that this attribute is always 1.  When I do a describeProcess request, I notice that the max_occurs is also equal to 1 and this happens regardless of whatever value I change the max_occurs to on that or any other LiteralInputs for my process.  So my question is, has anyone come across this issue?  Am I doing something wrong?  Below is the code showing how I have defined the inputs.

class BasicZonalStats(Process):
def __init__(self):
inputs = [ComplexInput('aoi_ndvi','Raster ndvi',
supported_formats=[Format('image/tiff'), Format('application/x-ogc-wcs')],
min_occurs=1, max_occurs=1, mode=MODE.NONE),
LiteralInput('band','the band to calculate stats for', data_type='integer', min_occurs=1, max_occurs=1,
mode=MODE.SIMPLE),
LiteralInput('stats', 'Statistics to calculate', data_type='string', min_occurs=0, max_occurs=9,
allowed_values=('sum', 'std', 'median', 'majority', 'minority', 'unique', 'range',
'nodata', 'nan'), mode=MODE.SIMPLE),
LiteralInput('nodata','Nodata value', data_type='integer',mode=MODE.SIMPLE),
ComplexInput('zones', 'Vector polygons to calculate stats on.',
supported_formats=[Format('application/json')],
min_occurs=1, max_occurs=1, mode=MODE.NONE)

]
outputs = [ComplexOutput('zonal_stats', 'Attribute Table',
supported_formats=[Format('application/json')],
)]

super(BasicZonalStats, self).__init__(
self._handler,
identifier='zonal',
version='0.1',
title="Basic Zonal Statistics using Rasterstats",
abstract="This is a naive and basic WPS, it assumes that both vector and raster inputs are in the same"
"projection and as such does not do any error checking. This will be fixed at a later stage so f"
"or now please ensure that the inputs are in the same projection.",
profile='',
inputs=inputs,
outputs=outputs,
store_supported=True,
status_supported=True
)
Any help with this would be much appreciated. 
Thanks,
Suzana
--

Dr Suzana Barreto
Software Analyst
Environment Systems

Tel: <a style="color:rgb(17,85,204)" href="tel:%2B44%20%280%29%201970%20626688" value="+441970626688" target="_blank">+44 (0) 1970 626688
www.envsys.co.uk

The information contained in this e-mail is intended only for the use of the person(s) to whom it is addressed and may contain confidential or privileged information. If you have received this e-mail in error please contact the sender and delete the material without copying, distributing or disclosing the content. All reasonable precautions have been taken to ensure that this e-mail is free from any virus, however, the recipient should verify this to be the case. Please 'think before you print'



--

Dr Suzana Barreto
Software Analyst
Environment Systems

Tel: <a style="color:rgb(17,85,204)" href="tel:%2B44%20%280%29%201970%20626688" value="+441970626688" target="_blank">+44 (0) 1970 626688
www.envsys.co.uk

The information contained in this e-mail is intended only for the use of the person(s) to whom it is addressed and may contain confidential or privileged information. If you have received this e-mail in error please contact the sender and delete the material without copying, distributing or disclosing the content. All reasonable precautions have been taken to ensure that this e-mail is free from any virus, however, the recipient should verify this to be the case. Please 'think before you print'


_______________________________________________
pywps-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pywps-dev
Reply | Threaded
Open this post in threaded view
|

Re: Question about process inputs

Luí­s Moreira de Sousa
Hi Suzana,

well spotted, this bug is present in the master branch. Please open a new issue, and if you are able to, then submit a matching pull request. As a reminder, detailed contribution instructions can be accessed here: https://pywps.readthedocs.io/en/latest/development.html

Thank you for contributing to PyWPS.

--
Luís Moreira de Sousa
Phone: +31 628 544 755
RingID: ring:7ca91d83f4f9dec82fec9f1144b8e5c1ef2a110c

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, November 6, 2018 5:08 PM, Suzana Barreto <[hidden email]> wrote:

Hi All,

I have found the bug which is in basic.py class LiteralInput, when it initialises BasicIO, it sets the min_occurs, max_occurs to 1 instead of using the passed in parameter.
Do I need to fix this in the code base, following the given procedures of course? 

Thanks,
Suzana


On Tue, 6 Nov 2018 at 15:09, Suzana Barreto <[hidden email]> wrote:
Hi All,

I am in the process of testing a process I created using PyWPS 4.  I have found an odd issue with the LiteralInputs for my process.  So for example, my process takes an input parameter (stats) where I have a max_occurs=9 which should allow for any number of strings detailing the statistics I would like calculated for a given input file. When I issue a request with a number of values ('sum', 'median', 'std') for that particular parameter, my response contains the result for only 1 of the statistics for that parameter.  I traced the issue to service.py (create_literal_inputs), line 216 where a deque is created using the LiteralInput's max_occurs parameter to limit the size.  Unfortunately, it appears that this attribute is always 1.  When I do a describeProcess request, I notice that the max_occurs is also equal to 1 and this happens regardless of whatever value I change the max_occurs to on that or any other LiteralInputs for my process.  So my question is, has anyone come across this issue?  Am I doing something wrong?  Below is the code showing how I have defined the inputs.

class BasicZonalStats(Process):
def __init__(self):
inputs = [ComplexInput('aoi_ndvi','Raster ndvi',
supported_formats=[Format('image/tiff'), Format('application/x-ogc-wcs')],
min_occurs=1, max_occurs=1, mode=MODE.NONE),
LiteralInput('band','the band to calculate stats for', data_type='integer', min_occurs=1, max_occurs=1,
mode=MODE.SIMPLE),
LiteralInput('stats', 'Statistics to calculate', data_type='string', min_occurs=0, max_occurs=9,
allowed_values=('sum', 'std', 'median', 'majority', 'minority', 'unique', 'range',
'nodata', 'nan'), mode=MODE.SIMPLE),
LiteralInput('nodata','Nodata value', data_type='integer',mode=MODE.SIMPLE),
ComplexInput('zones', 'Vector polygons to calculate stats on.',
supported_formats=[Format('application/json')],
min_occurs=1, max_occurs=1, mode=MODE.NONE)

]
outputs = [ComplexOutput('zonal_stats', 'Attribute Table',
supported_formats=[Format('application/json')],
)]

super(BasicZonalStats, self).__init__(
self._handler,
identifier='zonal',
version='0.1',
title="Basic Zonal Statistics using Rasterstats",
abstract="This is a naive and basic WPS, it assumes that both vector and raster inputs are in the same"
"projection and as such does not do any error checking. This will be fixed at a later stage so f"
"or now please ensure that the inputs are in the same projection.",
profile='',
inputs=inputs,
outputs=outputs,
store_supported=True,
status_supported=True
)
Any help with this would be much appreciated. 
Thanks,
Suzana
--

Dr Suzana Barreto
Software Analyst
Environment Systems

Tel: <a data-darkreader-inline-color="" style="color: rgb(17, 85, 204); --darkreader-inline-color:#7fb2e3;" href="tel:%2B44%20%280%29%201970%20626688" value="+441970626688" target="_blank">+44 (0) 1970 626688
www.envsys.co.uk

The information contained in this e-mail is intended only for the use of the person(s) to whom it is addressed and may contain confidential or privileged information. If you have received this e-mail in error please contact the sender and delete the material without copying, distributing or disclosing the content. All reasonable precautions have been taken to ensure that this e-mail is free from any virus, however, the recipient should verify this to be the case. Please 'think before you print'



--

Dr Suzana Barreto
Software Analyst
Environment Systems

Tel: <a data-darkreader-inline-color="" style="color: rgb(17, 85, 204); --darkreader-inline-color:#7fb2e3;" href="tel:%2B44%20%280%29%201970%20626688" value="+441970626688" target="_blank">+44 (0) 1970 626688
www.envsys.co.uk

The information contained in this e-mail is intended only for the use of the person(s) to whom it is addressed and may contain confidential or privileged information. If you have received this e-mail in error please contact the sender and delete the material without copying, distributing or disclosing the content. All reasonable precautions have been taken to ensure that this e-mail is free from any virus, however, the recipient should verify this to be the case. Please 'think before you print'



_______________________________________________
pywps-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pywps-dev