Skip to content

Commit

Permalink
tests for ncml pass
Browse files Browse the repository at this point in the history
  • Loading branch information
huard committed Apr 28, 2020
2 parents 5478c36 + dea910c commit a471dad
Show file tree
Hide file tree
Showing 22 changed files with 312 additions and 113 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changes
*******

0.11.1 (2020-01-03)
===================

Changes:

* pin PyWPS 4.2.x (#94).

0.11.0 (2019-09-27)
===================

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# vim:set ft=dockerfile:
FROM continuumio/miniconda3
MAINTAINER https://github.com/bird-house/emu
LABEL Description="Emu: Demo PyWPS" Vendor="Birdhouse" Version="0.11.0"
LABEL Description="Emu: Demo PyWPS" Vendor="Birdhouse" Version="0.11.1"

# Update Debian system
RUN apt-get update && apt-get install -y \
Expand Down
22 changes: 20 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
version: '3'
services:
emu:
# http://localhost:5000/wps
build: .
image: birdhouse/emu
image: birdhouse/emu:dev
ports:
- "5000:5000"
volumes:
- outputpath:/tmp

thredds:
# Thredds is used as DAP server for Emu outputs
# http://localhost:8080/thredds/catalog.html
image: unidata/thredds-docker:4.6.14
ports:
- "8080:8080"
volumes:
- ./threddsCatalog.xml:/usr/local/tomcat/content/thredds/catalog.xml:ro
- outputpath:/wps_outputs:ro

volumes:
outputpath: {}

# docker-compose build
# docker-compose up
# docker-compose down
# docker-compose down -v
# -v, --volumes Remove named volumes declared in the `volumes` section
# of the Compose file and anonymous volumes
# attached to containers.
# docker-compose rm
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# The short X.Y version.
version = ''
# The full version, including alpha/beta/rc tags.
release = '0.11.0'
release = '0.11.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion emu/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

__author__ = """Carsten Ehbrecht"""
__email__ = 'ehbrecht@dkrz.de'
__version__ = '0.11.0'
__version__ = '0.11.1'
1 change: 1 addition & 0 deletions emu/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ allowedinputpaths = /
maxsingleinputsize = 200mb
maxprocesses = 10
parallelprocesses = 2
language = en-US,fr-CA,de-DE

[logging]
level = INFO
Expand Down
5 changes: 3 additions & 2 deletions emu/processes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from .wps_nonpyid import NonPyID
from .wps_dry_run import SimpleDryRun
from .wps_ncml import NcMLAgg
from .wps_nc_to_dap import NcToDap
from .wps_translation import Translation


processes = [
UltimateQuestion(),
Expand All @@ -39,5 +40,5 @@
NonPyID(),
SimpleDryRun(),
NcMLAgg(),
NcToDap(),
Translation(),
]
5 changes: 4 additions & 1 deletion emu/processes/wps_nc_to_dap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@

LOGGER = logging.getLogger("PYWPS")

# This needs some more thoughts before going live to decide how the WPS server should be configured to communicate
# with the DAP server.


class NcToDap(Process):
def __init__(self):
inputs = [
ComplexInput('resource', "NetCDF file",
abstract="Link to NetCDF or NcML file on this server",
supported_formats=[FORMATS.NETCDF, FORMATS.NCML],
supported_formats=[FORMATS.NETCDF, ], # FORMATS.NCML], to become available in PyWPS 4.2.5
min_occurs=1,
max_occurs=1)
]
Expand Down
10 changes: 4 additions & 6 deletions emu/processes/wps_ncml.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

import xarray
import xarray.tests.test_dataset as td
from pywps import Process
from pywps import ComplexOutput, FORMATS
from pywps.app.Common import Metadata
Expand All @@ -21,7 +22,7 @@ def __init__(self):
supported_formats=[FORMATS.NETCDF]),
ComplexOutput('ncml', 'NcML aggregation',
as_reference=True,
supported_formats=[FORMATS.NCML, FORMATS.DODS]),
supported_formats=[FORMATS.DODS]), # FORMATS.NCML To become available in PyWPS 4.2.5
]

super(NcMLAgg, self).__init__(
Expand All @@ -39,7 +40,6 @@ def __init__(self):
status_supported=True)

def _handler(self, request, response):
import xarray.tests.test_dataset as td

# Create test datasets
d1, d2, _ = td.create_append_test_data()
Expand All @@ -64,8 +64,6 @@ def _handler(self, request, response):
response.outputs["d1"].file = d1fn
response.outputs["d2"].file = d2fn

with open(os.path.join(self.workdir, 'agg.ncml'), "w") as fp:
response.outputs['ncml'].file = fp.name
fp.write(ncml)
response.outputs['ncml'].data = ncml

return response
58 changes: 58 additions & 0 deletions emu/processes/wps_translation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
Translation process to check WPS translations
"""
from pywps import Process, LiteralInput, LiteralOutput

import logging
LOGGER = logging.getLogger("PYWPS")


class Translation(Process):
def __init__(self):
inputs = [
LiteralInput('input1', 'Input1 number',
default='100', data_type='integer',
translations={
"fr-CA": {"title": "Entrée #1", "abstract": "Entier #1"},
"de-DE": {"title": "Eingabe #1", "abstract": "Eingabe #1"},
}),
]
outputs = [
LiteralOutput('output1', 'Output1 add 1 result',
data_type='string',
translations={
"fr-CA": {"title": "Sortie #1", "abstract": "Chaîne de charactères"},
"de-DE": {"title": "Ausgabe #1", "abstract": "Ergebnis"}
}),
]

super(Translation, self).__init__(
self._handler,
identifier='translation',
title="Translated process",
abstract="Process including translations in other languages.",
version="1.0",
inputs=inputs,
outputs=outputs,
store_supported=True,
status_supported=True,
keywords=["languages"],
translations={
"fr-CA": {"title": "Processus traduit",
"abstract": "Processus incluant des traductions",
"keywords": ["langues"]},
"de-DE": {"title": "Mehrsprachiger Prozess",
"abstract": "Prozess mit mehreren Sprachen.",
"keywords": ["sprachen"]}
}
)

@staticmethod
def _handler(request, response):
response.update_status('PyWPS Process started.', 0)

LOGGER.debug("input1 %s", request.inputs['input1'][0].data)
response.outputs['output1'].data = request.inputs['input1'][0].data + 1

response.update_status('PyWPS Process completed.', 100)
return response
2 changes: 2 additions & 0 deletions emu/templates/pywps.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ outputpath= {{ wps_outputpath }}
{% if wps_workdir %}
workdir={{ wps_workdir }}
{% endif %}
languages = en-US,fr-CA,de-DE


[logging]
level = {{ wps_log_level|default('INFO') }}
Expand Down
7 changes: 4 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: emu
channels:
#- conda-forge
- conda-forge
- defaults
dependencies:
- pip
#- pywps=4.2
- python=3.6
- pywps=4.2
- jinja2
- click
- psutil
Expand All @@ -15,5 +16,5 @@ dependencies:
# tests
- pytest
- pip:
- -e git+https://github.com/geopython/pywps@master#egg=pywps
# - -e git+https://github.com/geopython/pywps@master#egg=pywps
- geomet
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pywps>=4.2.0
pywps>=4.2.4<4.3
jinja2
click
psutil
defusedxml
geomet
netCDF4
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.11.0
current_version = 0.11.1
commit = True
tag = True

Expand Down
Loading

0 comments on commit a471dad

Please sign in to comment.