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 os
import getpass
import lxml.etree as etree
import owslib
from owslib.wps import monitorExecution
from owslib.wps import WebProcessingService
from nbconvert.preprocessors import ExecutePreprocessor, CellExecutionError
import nbformat as nbf
  • Load the data pipeline configuration
In [2]:
%store -r

nb_config = os.path.join('../operations', 'configuration.ipynb')

nb = nbf.read(nb_config, 4)

exec(nb['cells'][1]['source']) in globals(), locals()

app = dict([('artifact_id', app_artifact_id),
            ('version', app_version),
            ('repository', repository),
            ('community', community)])

app_process_id = '%s_%s_%s_%s' % (app['community'].replace('-', '_'), app['artifact_id'].replace('-', '_'), app['artifact_id'].replace('-', '_'), app['version'].replace('.', '_'))
In [3]:
app_process_id
Out[3]:
'ec_better_ewf_wfp_01_01_01_ewf_wfp_01_01_01_1_20'
  • Connect to the WPS server and do a GetCapabilities request to check if the deploy process is available:
In [4]:
wps_url = '%s/zoo-bin/zoo_loader.cgi' % apps_deployer

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

wps.getcapabilities()
In [5]:
deploy_process_available = False

for index, elem in enumerate(wps.processes):

    if 'TerradueDeployProcess' in elem.identifier:

        deploy_process_available = True

if deploy_process_available:
    print 'TerradueDeployProcess is available'
else:
    raise Exception('TerradueDeployProcess is not available')
TerradueDeployProcess is available
  • 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
coordinator
In [7]:
for process_output in process.processOutputs:
    print process_output.identifier
deployResult
  • Create the OWS Context document URL:
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-wfp-01-01-01/1.20/ewf-wfp-01-01-01-1.20-application-context.xml'
  • Create the TerradueDeployProcess inputs
In [10]:
inputs = [('applicationPackage', ows_context_url),
          ('apikey', ellip_api_key),
         ('coordinator', 'False')]
  • Submit the TerradueDeployProcess Execute WPS request:
In [11]:
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 TerradueDeployProcess Execute request:
In [12]:
monitorExecution(execution)
  • Check if the application was successfully deployed
In [13]:
if execution.isSucceded():

    print 'Application %s deployment is successful' % app_process_id

else:

    raise Exception('Application %s deployment failed' % app_process_id)
Application ec_better_ewf_wfp_01_01_01_ewf_wfp_01_01_01_1_20 deployment is successful
  • List the WPS process available, the newly deployed process must be amongst the exposed process
In [14]:
wps = WebProcessingService(wps_url, verbose=False, skip_caps=True)

wps.getcapabilities()

app_deployed = False

for index, elem in enumerate(wps.processes):
    if elem.identifier == app_process_id:
        app_deployed = True

if app_deployed:
    print 'Process %s deployed' % app_process_id
else:
    raise Exception('Process %s not deployed' % app_process_id)
Process ec_better_ewf_wfp_01_01_01_ewf_wfp_01_01_01_1_20 deployed

The data transformation application is deployed!

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