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 [ ]:
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 [ ]:
%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('.', '_'))
- Connect to the WPS server and do a GetCapabilities request to check if the deploy process is available:
In [ ]:
wps_url = '%s/zoo-bin/zoo_loader.cgi' % apps_deployer
wps = WebProcessingService(wps_url, verbose=False, skip_caps=True)
wps.getcapabilities()
In [ ]:
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')
- Select the TerradueDeployProcess process to submit a DescribeProcess request and list the inputs and outputs:
In [ ]:
process_id = 'TerradueDeployProcess'
process = wps.describeprocess(process_id)
for data_input in process.dataInputs:
print data_input.identifier
In [ ]:
for process_output in process.processOutputs:
print process_output.identifier
- Create the OWS Context document URL:
In [ ]:
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 [ ]:
ows_context_url
- Create the TerradueDeployProcess inputs
In [ ]:
inputs = [('applicationPackage', ows_context_url),
('apikey', ellip_api_key)]
- Submit the TerradueDeployProcess Execute WPS request:
In [ ]:
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)
In [ ]:
process_id
- Monitor the TerradueDeployProcess Execute request:
In [ ]:
monitorExecution(execution)
- Check if the application was successfully deployed
In [ ]:
if execution.isSucceded():
print 'Application %s deployment is successful' % app_process_id
else:
raise Exception('Application %s deployment failed' % app_process_id)
- List the WPS process available, the newly deployed process must be amongst the exposed process
In [ ]:
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)
The data transformation application is deployed!
The next step, Test will submit a processing request using the Web Processing Service just exposed.