From 85e2a846429a0d02f2587ea426c0cdc449fae9d9 Mon Sep 17 00:00:00 2001 From: jpitts-uva Date: Wed, 17 Jan 2024 06:03:59 -0500 Subject: [PATCH 1/2] Fix to prevent continuing Sentry "Working outside of application context" error. --- crc/services/workflow_service.py | 45 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index e8ead7ee..89eb3e9d 100755 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -139,30 +139,31 @@ class WorkflowService(object): return workflow_url def process_erroring_workflows(self): - workflows = self.get_erroring_workflows() - if len(workflows) > 0: - workflow_urls = [] - if len(workflows) == 1: - workflow = workflows[0] - workflow_url_link = self.get_workflow_url(workflow) - workflow_urls.append(workflow_url_link) - message = 'There is one workflow in an error state.' - message += f'\n You can restart the workflow at {workflow_url_link}.' - else: - message = f'There are {len(workflows)} workflows in an error state.' - message += '\nYou can restart the workflows at these URLs:' - for workflow in workflows: + with app.app_context(): + workflows = self.get_erroring_workflows() + if len(workflows) > 0: + workflow_urls = [] + if len(workflows) == 1: + workflow = workflows[0] workflow_url_link = self.get_workflow_url(workflow) workflow_urls.append(workflow_url_link) - message += f'\n{workflow_url_link}' - - with push_scope() as scope: - scope.user = {"urls": workflow_urls} - scope.set_extra("workflow_urls", workflow_urls) - # this sends a message through sentry - capture_message(message) - # We return message so we can use it in a test - return message + message = 'There is one workflow in an error state.' + message += f'\n You can restart the workflow at {workflow_url_link}.' + else: + message = f'There are {len(workflows)} workflows in an error state.' + message += '\nYou can restart the workflows at these URLs:' + for workflow in workflows: + workflow_url_link = self.get_workflow_url(workflow) + workflow_urls.append(workflow_url_link) + message += f'\n{workflow_url_link}' + + with push_scope() as scope: + scope.user = {"urls": workflow_urls} + scope.set_extra("workflow_urls", workflow_urls) + # this sends a message through sentry + capture_message(message) + # We return message so we can use it in a test + return message @staticmethod def test_spec(spec_id, validate_study_id=None, test_until=None, required_only=False): From 189d47be75c1ca79b1f11a418ec8dab79713c55c Mon Sep 17 00:00:00 2001 From: jpitts-uva Date: Mon, 29 Jan 2024 02:20:56 -0500 Subject: [PATCH 2/2] Added eml and msg file types and associated content types. --- crc/models/file.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crc/models/file.py b/crc/models/file.py index e38a3704..502ba6ad 100644 --- a/crc/models/file.py +++ b/crc/models/file.py @@ -20,9 +20,11 @@ class FileType(enum.Enum): dmn = "dmn" doc = "doc" docx = "docx" + eml = "eml" gif = 'gif' jpg = 'jpg' md = 'md' + msg = 'msg' pdf = 'pdf' png = 'png' ppt = 'ppt' @@ -43,9 +45,11 @@ CONTENT_TYPES = { "dmn": "text/xml", "doc": "application/msword", "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "eml": "application/octet-stream", "gif": "image/gif", "jpg": "image/jpeg", "md": "text/plain", + "msg": "application/vnd.ms-outlook", "pdf": "application/pdf", "png": "image/png", "ppt": "application/vnd.ms-powerpoint",