{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pywps import ComplexInput, ComplexOutput, FORMATS, Format\n", "\n", "class Profile(object):\n", " def __init__(self, *args, **kwargs):\n", " super(Profile, self).__init__(*args, **kwargs)\n", " \n", " @property\n", " def inputs(self):\n", " return self._inputs\n", " \n", " @inputs.setter\n", " def inputs(self, values):\n", " if isinstance(values, list):\n", " self._inputs.extend(values)\n", "\n", "class ESGFAPI(Profile):\n", " def __init__(self, *args, **kwargs):\n", " self._inputs = [\n", " ComplexInput(\n", " 'test', 'Test',\n", " supported_formats=[FORMATS.JSON],\n", " ), ]\n", " super(ESGFAPI, self).__init__(*args, **kwargs)\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pywps import Process\n", "\n", "class EmuSubset(ESGFAPI, Process):\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.identifier)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "t = EmuSubset()\n", "len(t.inputs)" ] } ], "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 }