def success(self, appstruct): super(Done, self).success(appstruct) if appstruct.get('is_favorite', False): self.favorite.set( name=appstruct.get('favorite_name'), state=self.wizard_state.dump()) self.favorite.save() source_type = self.wizard_state.get('wizard_source')['source'] if source_type == 'wizard_upload': inputs = appstruct_to_inputs(self.request, self.wizard_state.get('wizard_literal_inputs', {})) resource = self.wizard_state.get('wizard_complex_inputs')['identifier'] for url in self.wizard_state.get('wizard_storage')['url']: inputs.append( (resource, url) ) logger.debug('storage inputs=%s', inputs) result = execute_process.delay( userid=authenticated_userid(self.request), url=self.wps.url, identifier=self.wizard_state.get('wizard_process')['identifier'], inputs=inputs, outputs=[]) self.request.registry.notify(JobStarted(self.request, result.id)) else: result = execute_workflow.delay( userid=authenticated_userid(self.request), url=self.request.wps.url, workflow=self.workflow_description()) self.request.registry.notify(JobStarted(self.request, result.id))
def execute(self, appstruct): inputs = appstruct_to_inputs(self.request, appstruct) # need to use ComplexDataInput complex_inpts = [] for inpt in self.process.dataInputs: if 'ComplexData' in inpt.dataType: complex_inpts.append(inpt.identifier) new_inputs = [] for inpt in inputs: if inpt[0] in complex_inpts: new_inputs.append((inpt[0], ComplexDataInput(inpt[1]))) else: new_inputs.append(inpt) inputs = new_inputs # prepare outputs outputs = [] for output in self.process.processOutputs: outputs.append( (output.identifier, output.dataType == 'ComplexData')) from phoenix.tasks.execute import execute_process result = execute_process.delay( userid=self.request.unauthenticated_userid, url=self.wps.url, service_name=self.service_name, identifier=self.process.identifier, inputs=inputs, outputs=outputs, async=appstruct.get('_async_check', True)) self.session['task_id'] = result.id self.request.registry.notify(JobStarted(self.request, result.id))
def workflow_description(self): # source_type source_type = self.wizard_state.get('wizard_source')['source'] workflow = dict(name=source_type, source={}, worker={}) # source user = self.get_user() if 'thredds' in source_type: source = dict() source['catalog_url'] = self.wizard_state.get( 'wizard_threddsbrowser').get('url') workflow['source']['thredds'] = source elif 'esgf' in source_type: selection = self.wizard_state.get( 'wizard_esgf_search')['selection'] source = json.loads(selection) source['url'] = self.request.registry.settings.get( 'esgfsearch.url') # source['credentials'] = user.get('credentials') workflow['source']['esgf'] = source elif 'solr' in source_type: state = self.wizard_state.get('wizard_solr') source = dict() source['url'] = self.request.registry.settings.get('solr.url') solr_query = state.get('query', '') if len(solr_query.strip()) == 0: solr_query = '*:*' source['query'] = solr_query source['filter_query'] = [] if state.get('category'): source['filter_query'].append("category:{0}".format( state.get('category'))) if state.get('source'): source['filter_query'].append("source:{0}".format( state.get('source'))) workflow['source']['solr'] = source else: raise Exception('Unknown source type') # worker literal_inputs = appstruct_to_inputs( self.request, self.wizard_state.get('wizard_literal_inputs', {})) # Use proxy wps url ... wps = WebProcessingService(url=self.request.route_url( 'owsproxy', service_name=self.service_name), verify=False, skip_caps=True) logger.debug("wizard worker wps url: %s", wps.url) worker = dict( url=wps.url, identifier=self.wizard_state.get('wizard_process')['identifier'], inputs=[(key, value) for key, value in literal_inputs], resource=self.wizard_state.get('wizard_complex_inputs') ['identifier'], ) workflow['worker'] = worker return workflow
def workflow_description(self): # source_type source_type = self.wizard_state.get('wizard_source')['source'] workflow = dict(name=source_type, source={}, worker={}) # source user = self.get_user() if 'swift' in source_type: source = dict( storage_url = user.get('swift_storage_url'), auth_token = user.get('swift_auth_token'), ) source['container'] = self.wizard_state.get('wizard_swiftbrowser').get('container') prefix = self.wizard_state.get('wizard_swiftbrowser').get('prefix') logger.debug('swift prefix = %s', prefix) if prefix is not None and len(prefix.strip()) > 0: source['prefix'] = prefix workflow['source']['swift'] = source elif 'thredds' in source_type: source = dict() source['catalog_url'] = self.wizard_state.get('wizard_threddsbrowser').get('url') workflow['source']['thredds'] = source elif 'esgf' in source_type: selection = self.wizard_state.get('wizard_esgf_search')['selection'] source = json.loads(selection) source['credentials'] = user.get('credentials') workflow['source']['esgf'] = source elif 'solr' in source_type: state = self.wizard_state.get('wizard_solr') source = dict() source['url'] = self.request.registry.settings.get('solr.url') solr_query = state.get('query', '') if len(solr_query.strip()) == 0: solr_query = '*:*' source['query'] = solr_query source['filter_query'] = [] if state.get('category'): source['filter_query'].append( "category:{0}".format(state.get('category')) ) if state.get('source'): source['filter_query'].append( "source:{0}".format(state.get('source')) ) workflow['source']['solr'] = source else: raise Exception('Unknown source type') # worker inputs = appstruct_to_inputs(self.request, self.wizard_state.get('wizard_literal_inputs', {})) worker_inputs = ['%s=%s' % (key, value) for key,value in inputs] worker = dict( url = self.wps.url, identifier = self.wizard_state.get('wizard_process')['identifier'], inputs = [(key, value) for key,value in inputs], resource = self.wizard_state.get('wizard_complex_inputs')['identifier'], ) workflow['worker'] = worker return workflow
def execute(self, appstruct): inputs = appstruct_to_inputs(self.request, appstruct) # need to use ComplexDataInput complex_inpts = {} bbox_inpts = [] for inpt in self.process.dataInputs: if 'ComplexData' in inpt.dataType: complex_inpts[inpt.identifier] = inpt elif 'BoundingBoxData' in inpt.dataType: bbox_inpts.append(inpt.identifier) new_inputs = [] for inpt in inputs: identifier = inpt[0] value = inpt[1] if identifier in complex_inpts: new_inputs.append((identifier, ComplexDataInput(value))) if is_reference(value): if value not in self.request.cart: if complex_inpts[identifier].supportedValues: mime_type = complex_inpts[ identifier].supportedValues[0].mimeType else: mime_type = None LOGGER.debug("add input to cart: %s %s", identifier, mime_type) self.request.cart.add_item( value, abstract= "Automatically added in process execution.", mime_type=mime_type) elif identifier in bbox_inpts: new_inputs.append((identifier, BoundingBoxDataInput(value))) else: new_inputs.append(inpt) inputs = new_inputs # prepare outputs outputs = [] for output in self.process.processOutputs: outputs.append( (output.identifier, output.dataType == 'ComplexData')) from phoenix.tasks.execute import execute_process result = execute_process.delay( userid=self.request.unauthenticated_userid, url=self.wps.url, service_name=self.service_name, identifier=self.process.identifier, inputs=inputs, outputs=outputs, async=appstruct.get('_async_check', True)) self.request.registry.notify(JobStarted(self.request, result.id)) return result.id
def execute(self, appstruct): inputs = appstruct_to_inputs(self.request, appstruct) outputs = [] for output in self.process.processOutputs: outputs.append( (output.identifier, output.dataType == 'ComplexData' ) ) from phoenix.tasks import execute_process result = execute_process.delay( userid=authenticated_userid(self.request), url=self.wps.url, identifier=self.process.identifier, inputs=inputs, outputs=outputs) self.request.registry.notify(JobStarted(self.request, result.id))
def execute(self, appstruct): inputs = appstruct_to_inputs(self.request, appstruct) # need to use ComplexDataInput complex_inpts = {} bbox_inpts = [] for inpt in self.process.dataInputs: if 'ComplexData' in inpt.dataType: complex_inpts[inpt.identifier] = inpt elif 'BoundingBoxData' in inpt.dataType: bbox_inpts.append(inpt.identifier) new_inputs = [] for inpt in inputs: identifier = inpt[0] value = inpt[1] if identifier in complex_inpts: new_inputs.append((identifier, ComplexDataInput(value))) elif identifier in bbox_inpts: crs = 'urn:ogc:def:crs:OGC:2:84' new_inputs.append((identifier, BoundingBoxDataInput(value, crs=crs))) else: new_inputs.append(inpt) inputs = new_inputs # prepare outputs outputs = [] for output in self.process.processOutputs: outputs.append( (output.identifier, output.dataType == 'ComplexData')) from phoenix.tasks.execute import execute_process result = execute_process.delay( userid=self.request.unauthenticated_userid, url=self.wps.url, service_name=self.service.title, identifier=self.process.identifier, inputs=inputs, outputs=outputs, use_async=appstruct.get('_async_check', True)) # give the job a chance to start sleep(1) self.request.registry.notify(JobStarted(self.request, result.id)) LOGGER.debug('wps url={}'.format(self.wps.url)) LOGGER.debug('request inputs = {}'.format(str(inputs))) return result.id