From 3ebb98d0f37f8cdaa8c093e2c4ad4a4bd9a6c18d Mon Sep 17 00:00:00 2001 From: bio-boris Date: Tue, 2 Jun 2020 01:33:22 -0500 Subject: [PATCH 1/2] Allow blank method success --- lib/execution_engine2/sdk/EE2Status.py | 40 ++++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/lib/execution_engine2/sdk/EE2Status.py b/lib/execution_engine2/sdk/EE2Status.py index 3dea820f4..2475c0eae 100644 --- a/lib/execution_engine2/sdk/EE2Status.py +++ b/lib/execution_engine2/sdk/EE2Status.py @@ -226,26 +226,28 @@ def _finish_job_with_success(self, job_id, job_output): output.version = job_output.get("version") output.id = ObjectId(job_output.get("id")) output.result = job_output.get("result") - try: - output.validate() - except Exception as e: - self.sdkmr.logger.debug(e) - error_message = "Something was wrong with the output object" - error_code = ErrorCode.job_missing_output.value - error = { - "code": -1, - "name": "Output object is invalid", - "message": str(e), - "error": str(e), - } - self.sdkmr.get_mongo_util().finish_job_with_error( - job_id=job_id, - error_message=error_message, - error_code=error_code, - error=error, - ) - raise Exception(str(e) + str(error_message)) + if output != {}: + try: + output.validate() + except Exception as e: + self.sdkmr.logger.debug(e) + error_message = "Something was wrong with the output object" + error_code = ErrorCode.job_missing_output.value + error = { + "code": -1, + "name": "Output object is invalid", + "message": str(e), + "error": str(e), + } + + self.sdkmr.get_mongo_util().finish_job_with_error( + job_id=job_id, + error_message=error_message, + error_code=error_code, + error=error, + ) + raise Exception(str(e) + str(error_message)) self.sdkmr.get_mongo_util().finish_job_with_success( job_id=job_id, job_output=job_output From 42ec492707e5ac049fb55925afa58e7bb87037c0 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Tue, 2 Jun 2020 01:35:37 -0500 Subject: [PATCH 2/2] Allow blank method success --- lib/execution_engine2/sdk/EE2Status.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/execution_engine2/sdk/EE2Status.py b/lib/execution_engine2/sdk/EE2Status.py index 2475c0eae..71b8eb5d0 100644 --- a/lib/execution_engine2/sdk/EE2Status.py +++ b/lib/execution_engine2/sdk/EE2Status.py @@ -222,12 +222,18 @@ def _finish_job_with_error(self, job_id, error_message, error_code, error=None): ) def _finish_job_with_success(self, job_id, job_output): + """ + Allow either blank job outputs or outputs in a specific format (version/id/result) + + :param job_id: The job to finish + :param job_output: Either the job output or {}, else something is not right + """ output = JobOutput() output.version = job_output.get("version") output.id = ObjectId(job_output.get("id")) output.result = job_output.get("result") - if output != {}: + if job_output != {}: try: output.validate() except Exception as e: