Deploy the application on the Production CentreΒΆ

This Jupyter Notebook creates a Web Processing Request to deploy the data transformation application on the Production Centre.

  • First do the imports of the Python libraries required
In [1]:
import getpass
import lxml.etree as etree
import owslib
from owslib.wps import monitorExecution
from owslib.wps import WebProcessingService
  • Set the authentication and application to deploy information
In [2]:
api_key = getpass.getpass('Your Ellip API key:')
In [3]:
app = dict([('artifact_id', 'ewf-ethz-01-03-01'),
            ('version', '0.2'),
            ('repository', 'Gitlab Groups'),
            ('community', 'ec-better')])


app_process_id = '%s_%s_%s_%s' % (app['community'].replace('-', '_'), app['artifact_id'].replace('-', '_'), app['artifact_id'].replace('-', '_'), app['version'].replace('.', '_'))
  • Connect to the WPS server and do a GetCapabilities request to list the available process:
In [4]:
wps_url = 'https://ec-better-apps-deployer.terradue.com/zoo-bin/zoo_loader.cgi'

wps = WebProcessingService(wps_url, verbose=False, skip_caps=True)

wps.getcapabilities()
In [5]:
for index, elem in enumerate(wps.processes):
    print(index, elem.identifier)
(0, 'ec_better_ewf_wfp_01_02_02_ewf_wfp_01_02_02_0_1')
(1, 'ec_better_ewf_wfp_01_01_02_wfp_01_01_02_0_1')
(2, 'ec_better_wfp_01_01_01_wfp_01_01_01_1_5')
(3, 'ec_better_ewf_sen2cor_sen2cor_0_3')
(4, 'ec_better_ewf_ethz_01_01_01_ewf_ethz_01_01_01_0_2')
(5, 'ec_better_ewf_wfp_01_01_01_ewf_wfp_01_01_01_1_9')
(6, 'ec_better_wfp_01_01_01_wfp_01_01_01_0_4')
(7, 'ec_better_wfp_01_01_01_wfp_01_01_01_1_7')
(8, 'TerradueUnDeployProcess')
(9, 'ec_better_ewf_sen2cor_sen2cor_0_4')
(10, 'ec_better_ewf_ethz_01_01_01_ewf_ethz_01_01_01_0_1')
(11, 'ec_better_wfp_01_01_01_wfp_01_01_01_1_1')
(12, 'ec_better_ewf_sen2cor_sen2cor_0_1')
(13, 'ec_better_wfp_01_01_01_wfp_01_01_01_0_1')
(14, 'ec_better_ewf_ethz_01_03_01_ewf_ethz_01_03_01_0_2')
(15, 'ec_better_ewf_wfp_01_01_02_ewf_wfp_01_01_02_0_2')
(16, 'ec_better_wfp_01_01_01_wfp_01_01_01_1_6')
(17, 'GetStatus')
(18, 'ec_better_ewf_sen2cor_ewf_sen2cor_0_6')
(19, 'ec_better_wfp_01_01_01_wfp_01_01_01_1_2')
(20, 'TerradueDeployProcess')
(21, 'ec_better_ewf_sen2cor_sen2cor_0_2')
(22, 'ec_better_wfp_01_01_01_a_wfp_01_01_01_0_1')
(23, 'ec_better_wfp_01_01_01_wfp_01_01_01_1_0')
  • Select the TerradueDeployProcess process to submit a DescribeProcess request and list the inputs and outputs:
In [6]:
process_id = 'TerradueDeployProcess'

process = wps.describeprocess(process_id)

for data_input in process.dataInputs:
    print data_input.identifier

applicationPackage
apikey
In [7]:
for process_output in process.processOutputs:
    print process_output.identifier
deployResult
  • Build the Python dictionary with the inputs:
In [8]:
ows_context_url = '/%s/_applications/%s/%s/%s/%s-%s-application-context.xml' % (app['community'],
                                                                                app['community'],
                                                                                app['artifact_id'],
                                                                                app['version'],
                                                                                app['artifact_id'],
                                                                                app['version'])

In [9]:
ows_context_url
Out[9]:
'/ec-better/_applications/ec-better/ewf-ethz-01-03-01/0.2/ewf-ethz-01-03-01-0.2-application-context.xml'
In [10]:
inputs = [('applicationPackage', ows_context_url),
          ('apikey', api_key)]
  • Submit the Execute WPS request:
In [15]:
execution = owslib.wps.WPSExecution(url=wps.url)

execution_request = execution.buildRequest(process_id,
                                           inputs,
                                           output=[('deployResult', False)])

execution_response = execution.submitRequest(etree.tostring(execution_request))

execution.parseResponse(execution_response)
  • Monitor the request:
In [16]:
monitorExecution(execution)
 owslib.wps.WPSException : {'locator': None, 'code': 'InternalError', 'text': 'Unable to run the Service. The message returned back by the Service was the following: GetStatus was unable to find any cache file for Service ID 8fd9128a-a218-11e8-be08-0242ac110007.'}

KeyboardInterruptTraceback (most recent call last)
<ipython-input-16-1cd684eda421> in <module>()
----> 1 monitorExecution(execution)

/opt/anaconda/lib/python2.7/site-packages/owslib/wps.pyc in monitorExecution(execution, sleepSecs, download, filepath)
   1629
   1630     while execution.isComplete() == False:
-> 1631         execution.checkStatus(sleepSecs=sleepSecs)
   1632         log.info('Execution status: %s' % execution.status)
   1633

/opt/anaconda/lib/python2.7/site-packages/owslib/wps.pyc in checkStatus(self, url, response, sleepSecs)
    663         if self.isComplete() == False:
    664             log.info('Sleeping %d seconds...' % sleepSecs)
--> 665             sleep(sleepSecs)
    666
    667     def getStatus(self):

KeyboardInterrupt:
  • Check if the application was successfully deployed
In [22]:
if execution.isSucceded():

    print 'Application deployed!'

else:

    print 'Application not deployed :-('
Application deployed!
  • List the WPS process available, the newly deployed process must be amongst the exposed process
In [13]:
wps = WebProcessingService(wps_url, verbose=False, skip_caps=True)

wps.getcapabilities()
In [14]:
for index, elem in enumerate(wps.processes):
    if elem.identifier == app_process_id:
        print 'Process %s deployed' % app_process_id
Process ec_better_ewf_ethz_01_03_01_ewf_ethz_01_03_01_0_2 deployed

The next step, Test will submit a processing request using the Web Processing Service just exposed.