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_step_status_start(self, mock_job_update, mock_step_update): step = step_status("any jobid", "any stepid", STATUS_START) mock_step_update.assert_called_with({ 'id': 'any stepid', 'status': 'started', 'start': mock.ANY }) mock_job_update.assert_not_called()
def test_step_status_ok(self, mock_job_update, mock_step_update): step = step_status("any jobid", "any stepid", STATUS_OK) mock_step_update.assert_called_with({ 'id': 'any stepid', 'status': 'ended', 'end': mock.ANY }) mock_job_update.assert_not_called()
def test_step_status_fail(self, mock_job_update, mock_step_update): step = step_status("any jobid", "any stepid", STATUS_FAIL) mock_step_update.assert_called_with({ 'id': 'any stepid', 'status': 'failed', 'end': mock.ANY }) mock_job_update.assert_called_with({ 'id': 'any jobid', 'end': mock.ANY, 'status': 'ended' })
def on_workflow_progress(msg): """ Process a workflow progress message The progress report is START, OK or FAIL :param msg: The message that contains the progress info :return: None """ status = msg['status'] step_info = step_status(msg['jobid'], msg['stepid'], status) if step_info and status in [STATUS_OK, STATUS_FAIL]: logger.configure(msg, "WORKFLOW") logger.info( f"Duration {str(step_info.end - step_info.start).split('.')[0]}") if status == STATUS_FAIL: logger.error(f"Program error: {msg['info_msg']}") logger.info("End of workflow") hooks.on_workflow_progress(msg)