{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Process func decorator\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pywps import ComplexInput, ComplexOutput, FORMATS, Format\n", "from pywps import Process" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def esgfapi(F):\n", " def wrapper(self):\n", " F(self)\n", " self.profile.append('ESGF-API')\n", " self.inputs.extend([\n", " ComplexInput(\n", " 'test', 'Test ESGF API Param',\n", " supported_formats=[FORMATS.JSON],\n", " ), ])\n", " return wrapper" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "class EmuSubset(Process):\n", " @esgfapi\n", " def __init__(self):\n", " inputs = [\n", " ComplexInput(\n", " 'domain', 'domain',\n", " abstract=\"\",\n", " supported_formats=[FORMATS.JSON],\n", " min_occurs=0, max_occurs=1,\n", " ),\n", " ]\n", " outputs = [\n", " ComplexOutput(\n", " 'output', 'Output',\n", " as_reference=True,\n", " supported_formats=[FORMATS.NETCDF], ), ]\n", " \n", " super(EmuSubset, self).__init__(\n", " self._handler,\n", " identifier='Emu.subset',\n", " title='xarray.subset',\n", " abstract=\"subset netcdf files\",\n", " version='1',\n", " inputs=inputs,\n", " outputs=outputs,\n", " store_supported=True,\n", " status_supported=True)\n", " \n", " def _handler(self, request, response):\n", " pass" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "p = EmuSubset()\n", "for inpt in p.inputs:\n", " print(inpt.title)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "p.profile" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.7" } }, "nbformat": 4, "nbformat_minor": 2 }