from rooki import rooki
# The same as using birdy
#from birdy import WPSClient
#url = 'https://bovec.dkrz.de/ows/proxy/roocs'
#url = 'http://localhost:5000/wps'
#rooki = WPSClient(url, verify=False)
rooki?
Type: WPSClient String form: <birdy.client.base.WPSClient object at 0x10a16af70> File: ~/.conda/envs/rooki/lib/python3.8/site-packages/birdy/client/base.py Docstring: A demostrator for a WPS service for roocs. Processes --------- subset Run subsetting on climate data. average Run averaging on climate data. orchestrate Run a workflow Class docstring: Returns a class where every public method is a WPS process available at the given url. Example: >>> emu = WPSClient(url='<server url>') >>> emu.hello('stranger') 'Hello stranger' Init docstring: Args: url (str): Link to WPS provider. config (Config): an instance processes: Specify a subset of processes to bind. Defaults to all processes. converters (dict): Correspondence of {mimetype: class} to convert this mimetype to a python object. username (str): passed to :class:`owslib.wps.WebProcessingService` password (str): passed to :class:`owslib.wps.WebProcessingService` headers (str): passed to :class:`owslib.wps.WebProcessingService` auth (requests.auth.AuthBase): requests-style auth class to authenticate, see https://2.python-requests.org/en/master/user/authentication/ verify (bool): passed to :class:`owslib.wps.WebProcessingService` cert (str): passed to :class:`owslib.wps.WebProcessingService` verbose (str): passed to :class:`owslib.wps.WebProcessingService` progress (bool): If True, enable interactive user mode. version (str): WPS version to use.
rooki.subset?
Signature: rooki.subset( data_ref='cmip5.output1.MOHC.HadGEM2-ES.rcp85.mon.atmos.Amon.r1i1p1.latest.tas', time='2085-01-01/2120-12-30', pre_checked=False, space='-5.,49.,10.,65', level=1000, ) Docstring: Run subsetting on climate data. Parameters ---------- data_ref : string Data references time : string Time Period space : string Bounding Box level : integer Level pre_checked : boolean Use checked data only. Returns ------- output : ComplexData:mimetype:`application/x-netcdf` Output File: ~/Documents/GitHub/roocs/rooki/notebooks/</Users/pingu/.conda/envs/rooki/lib/python3.8/site-packages/birdy/client/base.py-0> Type: method
resp_subset = rooki.subset(
data_ref='cmip5.output1.MOHC.HadGEM2-ES.rcp85.mon.atmos.Amon.r1i1p1.latest.tas',
time='2085-01-01/2120-12-30',
)
resp_subset.get()
subsetResponse( output='https://bovec.dkrz.de/download/outputs/roocswps/26797ff0-6a08-11ea-94ce-109836a7cf3a/output.nc' )
rooki.average?
Signature: rooki.average( data_ref='cmip5.output1.MOHC.HadGEM2-ES.rcp85.mon.atmos.Amon.r1i1p1.latest.tas', axes='time', pre_checked=False, ) Docstring: Run averaging on climate data. Parameters ---------- data_ref : string Data references axes : {'time', 'latitude', 'longitude'}string Please choose an axes for averaging. pre_checked : boolean Use checked data only. Returns ------- output : ComplexData:mimetype:`text/plain` Output File: ~/Documents/GitHub/roocs/rooki/notebooks/</Users/pingu/.conda/envs/rooki/lib/python3.8/site-packages/birdy/client/base.py-1> Type: method
rooki.orchestrate?
Signature: rooki.orchestrate(workflow=None, mode='tree') Docstring: Run a workflow Parameters ---------- workflow : ComplexData:mimetype:`application/json` Workflow mode : {'tree', 'simple'}string Mode Returns ------- output : ComplexData:mimetype:`application/x-netcdf` Output File: ~/Documents/GitHub/roocs/rooki/notebooks/</Users/pingu/.conda/envs/rooki/lib/python3.8/site-packages/birdy/client/base.py-2> Type: method
Simple Workflow Chain
wf_simple = {
'doc': "simple workflow",
'inputs': {
'data_ref': ['cmip5.output1.MOHC.HadGEM2-ES.rcp85.mon.atmos.Amon.r1i1p1.latest.tas'],
},
'steps': [
{'subset': {"time": "2085-01-01/2120-12-30"}},
{'subset': {"time": "2090-01-01/2100-12-30"}},
{'average': {"axes": "time"}}
]}
import json
wf_simple_json = json.dumps(wf_simple)
wf_simple_json
'{"doc": "simple workflow", "inputs": {"data_ref": ["cmip5.output1.MOHC.HadGEM2-ES.rcp85.mon.atmos.Amon.r1i1p1.latest.tas"]}, "steps": [{"subset": {"time": "2085-01-01/2120-12-30"}}, {"subset": {"time": "2090-01-01/2100-12-30"}}, {"average": {"axes": "time"}}]}'
resp_wf = rooki.orchestrate(workflow=wf_simple_json, mode='simple')
resp_wf.get()
orchestrateResponse( output='https://bovec.dkrz.de/download/outputs/roocswps/314957de-6a08-11ea-94ce-109836a7cf3a/output.nc' )
Workflow with Function Tree
wf_tree = {
'doc': "tree workflow",
'inputs': {
'tas': ['cmip5.output1.MOHC.HadGEM2-ES.rcp85.mon.atmos.Amon.r1i1p1.latest.tas'],
},
"outputs": {
"output": "average_tas/output"
},
'steps': {
"subset_tas_1": {
"run": "subset",
"in": {
"data_ref": "inputs/tas",
"time": "2085-01-01/2120-12-30"
}
},
"subset_tas_2": {
"run": "subset",
"in": {
"data_ref": "subset_tas_1/output",
"time": "2090-01-01/2100-12-30"
}
},
"average_tas": {
"run": "average",
"in": {
"data_ref": "subset_tas_2/output",
"axes": "time"
}
}
}}
wf_tree_json = json.dumps(wf_tree)
wf_tree_json
'{"doc": "tree workflow", "inputs": {"tas": ["cmip5.output1.MOHC.HadGEM2-ES.rcp85.mon.atmos.Amon.r1i1p1.latest.tas"]}, "outputs": {"output": "average_tas/output"}, "steps": {"subset_tas_1": {"run": "subset", "in": {"data_ref": "inputs/tas", "time": "2085-01-01/2120-12-30"}}, "subset_tas_2": {"run": "subset", "in": {"data_ref": "subset_tas_1/output", "time": "2090-01-01/2100-12-30"}}, "average_tas": {"run": "average", "in": {"data_ref": "subset_tas_2/output", "axes": "time"}}}}'
resp_wf = rooki.orchestrate(workflow=wf_tree_json, mode='tree')
resp_wf.get()
orchestrateResponse( output='https://bovec.dkrz.de/download/outputs/roocswps/382a84a6-6a08-11ea-94ce-109836a7cf3a/output.nc' )
Function Tree with diff operator (multiple inputs)
wf_tree = {
'doc': "tree workflow with diff operator",
'inputs': {
'inm': ['cmip5.output1.INM.inmcm4.rcp45.mon.ocean.Omon.r1i1p1.latest.zostoga'],
'mpi': ['cmip5.output1.MPI-M.MPI-ESM-LR.rcp45.mon.ocean.Omon.r1i1p1.latest.zostoga']
},
"outputs": {
"output": "diff/output"
},
'steps': {
"subsetA": {
"run": "subset",
"in": {
"data_ref": "inputs/inm",
"time": "2085-01-01/2120-12-30"
}
},
"subsetB": {
"run": "subset",
"in": {
"data_ref": "inputs/mpi",
"time": "2085-01-01/2120-12-30"
}
},
"diff": {
"run": "diff",
"in": {
"data_ref_a": "subsetA/output",
"data_ref_b": "subsetB/output",
}
}
}}
wf_tree_json = json.dumps(wf_tree)
wf_tree_json
'{"doc": "tree workflow with diff operator", "inputs": {"inm": ["cmip5.output1.INM.inmcm4.rcp45.mon.ocean.Omon.r1i1p1.latest.zostoga"], "mpi": ["cmip5.output1.MPI-M.MPI-ESM-LR.rcp45.mon.ocean.Omon.r1i1p1.latest.zostoga"]}, "outputs": {"output": "diff/output"}, "steps": {"subsetA": {"run": "subset", "in": {"data_ref": "inputs/inm", "time": "2085-01-01/2120-12-30"}}, "subsetB": {"run": "subset", "in": {"data_ref": "inputs/mpi", "time": "2085-01-01/2120-12-30"}}, "diff": {"run": "diff", "in": {"data_ref_a": "subsetA/output", "data_ref_b": "subsetB/output"}}}}'
resp_wf = rooki.orchestrate(workflow=wf_tree_json, mode='tree')
resp_wf.get()
orchestrateResponse( output='https://bovec.dkrz.de/download/outputs/roocswps/409b1a74-6a08-11ea-94ce-109836a7cf3a/output.nc' )