Example #1
0
 def test_job_json(self):
     new_job = Job.from_json(json.loads(self.job.json))
     self.assertEqual(new_job.name, 'inout')
     self.assertEqual(new_job.uuid, str(self.uuid))
     self.assertEqual(new_job.workdir, '/tmp')
     self.assertEqual(len(new_job.process.inputs), 3)
     self.assertEqual(new_job.json, self.job.json)  # idempotent test
Example #2
0
def launch_process():
    """Look at the queue of async process, if the queue is not empty launch
    the next pending request.
    """
    try:
        from pywps.processing.job import Job

        LOGGER.debug("Checking for stored requests")

        stored_request = dblog.pop_first_stored()
        if not stored_request:
            LOGGER.debug("No stored request found, sleeping")
            return

        value = {
            'process': json.loads(stored_request.process.decode("utf-8")),
            'wps_request': json.loads(stored_request.request.decode("utf-8"))
        }
        job = Job.from_json(value)

        processing_process = pywps.processing.Process(
            process=job.process,
            wps_request=job.wps_request,
            wps_response=job.wps_response)
        processing_process.start()

    except Exception as e:
        LOGGER.exception("Could not run stored process. {}".format(e))
        raise e
Example #3
0
    def test_insert_request(self):

        requests = self.session.query(RequestInstance)
        assert requests.count() == 0

        obj = {
            'operation': 'execute',
            'version': '1.0.0',
            'language': 'eng',
            'identifier': 'multiple-outputs',
            'store_execute': True,
            'status': True,
            'lineage': True,
            'inputs': {
                'count': [{
                    'identifier': 'count',
                    'type': 'literal',
                    'data': 3
                }]
            },
            'outputs': {},
            'raw': False
        }

        request = WPSRequest()
        request.json = obj

        from .processes.metalinkprocess import MultipleOutputs
        process = MultipleOutputs()
        process.uuid = uuid.uuid4()
        store_request(process.uuid, request, process)

        requests = self.session.query(RequestInstance)
        assert requests.count() == 1
        stored_request = pop_first_stored()

        job = Job.from_json({
            "process": json.loads(stored_request.process),
            "wps_request": json.loads(stored_request.request)
        })

        assert job.process.identifier == "multiple-outputs"
        assert str(job.process.uuid) == str(process.uuid)

        requests = self.session.query(RequestInstance)
        assert requests.count() == 0
Example #4
0
 def test_job_json(self):
     new_job = Job.from_json(json.loads(self.job.json))
     self.assertEqual(new_job.name, 'greeter')
     self.assertEqual(new_job.uuid, str(self.uuid))
     self.assertEqual(new_job.workdir, '/tmp')
     self.assertEqual(len(new_job.process.inputs), 1)