Skip to content

Commit

Permalink
fixed sleep and tn process, update pywps.
Browse files Browse the repository at this point in the history
  • Loading branch information
cehbrecht committed Aug 8, 2018
1 parent 759a83d commit f9d7210
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
5 changes: 1 addition & 4 deletions ecaswps/processes/wps_index_tn.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import os
import tempfile
from pywps import Process, LiteralInput, ComplexOutput
from pywps import Format
from pywps.app.Common import Metadata

from ecaswps import util


# ALLOWED_VALUES = {
# 'model':
# 'ACCESS1-0 ACCESS1-3 bcc-csm1-1 bcc-csm1-1-m BNU-ESM CanCM4 '
Expand Down Expand Up @@ -74,8 +72,7 @@ def _handler(self, request, response):
from ecaswps.toolbox import tropical_nights
response.update_status('Calculting TN ...', 0)
# output in workdir
# output_filename = os.path.join(self.workdir, 'output.png')
_, output_filename = tempfile.mkstemp(suffix=".png", prefix="output-")
output_filename = os.path.join(self.workdir, 'tn_plot.png')
# start TN
tropical_nights(
dataset=request.inputs['dataset'][0].data,
Expand Down
4 changes: 2 additions & 2 deletions ecaswps/processes/wps_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Sleep(Process):
def __init__(self):
inputs = [
LiteralInput('delay', 'Delay between every update',
default='10', data_type='float')
default='2', data_type='float')
]
outputs = [
LiteralOutput('sleep_output', 'Sleep Output', data_type='string')
Expand Down Expand Up @@ -36,7 +36,7 @@ def _handler(request, response):
if 'delay' in request.inputs:
sleep_delay = request.inputs['delay'][0].data
else:
sleep_delay = 10
sleep_delay = 2

time.sleep(sleep_delay)
response.update_status('PyWPS Process started. Waiting...', 20)
Expand Down
4 changes: 2 additions & 2 deletions ecaswps/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def tropical_nights(dataset, output):
password=configuration.get_config_value('ophidia', 'password'),
server=configuration.get_config_value('ophidia', 'server'),
port=configuration.get_config_value('ophidia', 'port'))
# # Import source data (minimum temperature °K)
# Import source data (minimum temperature K)
mintemp = cube.Cube(
src_path=dataset,
measure='temp2',
Expand All @@ -38,7 +38,7 @@ def tropical_nights(dataset, output):
dim='time',
concept_level='y',
)
# # Plot the result
# Plot the result
firstyear = count.subset(subset_filter=1, subset_dims='time')
data = firstyear.export_array(show_time='yes')
lats = data['dimension'][0]['values'][:]
Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ channels:
- conda-forge
- defaults
dependencies:
- pywps=4.1.0
- pywps=4.1.2
- owslib=0.17
- jinja2
- click
- psutil
Expand Down
2 changes: 0 additions & 2 deletions etc/debug.cfg

This file was deleted.

6 changes: 6 additions & 0 deletions etc/demo.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
[logging]
level = WARN

[ophidia]
username = demo
password = demo
server = localhost
port = 11732
2 changes: 1 addition & 1 deletion tests/test_wps_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@pytest.mark.slow
def test_wps_sleep():
client = client_for(Service(processes=[Sleep()]))
datainputs = "deplay=1"
datainputs = "delay=0.1"
resp = client.get(
service='WPS', request='Execute', version='1.0.0', identifier='sleep',
datainputs=datainputs)
Expand Down

0 comments on commit f9d7210

Please sign in to comment.