In [1]:
    
##############################
# load the required libraries 
#############################
from owslib.wps import WebProcessingService, monitorExecution, printInputOutput
from os import system
import time
    
In [2]:
    
#################################################
# connect to the compute provider hosting the WPS
#################################################
wps_url = "http://birdhouse-lsce.extra.cea.fr:8093/wps"
#wps_url = "http://localhost:8093/wps"
wps = WebProcessingService(url=wps_url, verbose=False)
    
In [3]:
    
##########################################
# print some information about the service
##########################################
print wps.identification.title + ':'
print '#############'
for process in wps.processes:
    print '%s : \t %s' % (process.identifier, process.abstract)
    
    
In [4]:
    
#################################################
# print some information about a specific process
#################################################
# to recieve informations uncomment the follwing lines
#p = wps.describeprocess(identifier='analogs_detection')
#for input in p.dataInputs:
#    printInputOutput(input)
#    print '\n'
    
There are different ways to call a WPS service. The following cells are examples of the same process execution with different execution settings.
In [5]:
    
# get information about the call command:
wps.execute?
    
In [6]:
    
#####################
# execute the process
#####################
# call asyncon with sleepSecs
start_time = time.time()
execute = wps.execute(
    identifier="analogs_detection", 
    inputs=[("dist",'euclidean')], async=True)
monitorExecution(execute, sleepSecs=1)
print time.time() - start_time, "seconds"
print execute.getStatus()
for o in execute.processOutputs:
    print o.reference
    
    
In [7]:
    
#####################
# execute the process
#####################
# call syncron
start_time = time.time()
execute = wps.execute(
    identifier="analogs_detection", 
    inputs=[("dist",'euclidean')], async=False)
print time.time() - start_time, "seconds"
print execute.getStatus()
for o in execute.processOutputs:
    print o.reference
    
    
In [8]:
    
# case 1, async
inputs=[("dateSt",'2013-01-01'),("dateEn",'2014-12-31'),("refSt",'1990-01-01'),("refEn",'1995-12-31')]
start_time = time.time()
execute = wps.execute(identifier="analogs_detection", inputs=inputs, async=True)
monitorExecution(execute, sleepSecs=1)
print time.time() - start_time, "seconds"
print execute.getStatus()
for o in execute.processOutputs:
    print o.reference
    
    
In [ ]:
    
    
In [12]:
    
# the output of the previous analogs_detection process
analogs_output = execute.processOutputs[0].reference
print analogs_output
    
    
In [10]:
    
##########################################
# print some information about the process
##########################################
p = wps.describeprocess(identifier='analogs_viewer')
for input in p.dataInputs:
    printInputOutput(input)
    print '\n'
    
    
In [13]:
    
###########################################
# and execute the process for visualisation 
###########################################
viewer = wps.execute(identifier="analogs_viewer", 
                     inputs=[('resource', analogs_output)], 
                     async=False)
print viewer.getStatus()
for o in viewer.processOutputs:
    print o.reference
    
    
In [ ]: