def end_of_workflow(self, msg): logger.configure(msg, "WORKFLOW") on_complete = msg['header'].pop('on_workflow_complete', None) if on_complete is not None: if not isinstance(on_complete, dict) or not all([key in on_complete for key in ['exchange', 'key']]): logger.error("on_workflow_complete should be a dict with keys 'exchange' and 'key'") else: publish(on_complete['exchange'], on_complete['key'], msg) logger.info(f"Publish on_workflow_complete to {on_complete['exchange']} with {on_complete['key']}") logger.info("End of workflow") job_end(msg["header"].get("jobid"))
def reject(self, msg, job): """ Reject a message because the job is already active within GOB :param msg: :param job: :return: """ # Start a workflow step to reject the message msg["header"]["process_id"] = job['id'] msg["header"]["entity"] = msg["header"].get('collection') step = step_start("accept", msg['header']) step_status(job['id'], step['id'], STATUS_START) # End the workflow step and then the workflow job step_status(job['id'], step['id'], STATUS_REJECTED) return job_end(job['id'], STATUS_REJECTED)
def test_job_end_missing_id(self): job = job_end(None) self.assertIsNone(job)
def test_job_end(self): job = job_end("any jobid") self.assertEqual(job["id"], "any jobid") self.assertIsInstance(job["end"], datetime.datetime) self.assertEqual(job["status"], "ended")
def end_of_workflow(self, msg): logger.configure(msg, "WORKFLOW") logger.info(f"End of workflow") job_end(msg["header"].get("jobid"))