예제 #1
0
    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
        from phoenix.utils import appstruct_to_inputs
        inputs = appstruct_to_inputs(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
예제 #2
0
    def execute(self, appstruct):
        from phoenix.utils import appstruct_to_inputs

        inputs = appstruct_to_inputs(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))