From e9cc5384d9de4e1b6d461b3be540ef0f5cf2fcd9 Mon Sep 17 00:00:00 2001 From: Devin Gaffney Date: Wed, 31 Jul 2024 09:59:04 -0700 Subject: [PATCH 1/5] CV2-5001 remove parsing restriction on output --- lib/queue/processor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/queue/processor.py b/lib/queue/processor.py index 6f54a2a..66c6684 100644 --- a/lib/queue/processor.py +++ b/lib/queue/processor.py @@ -44,7 +44,7 @@ def send_callbacks(self) -> List[schemas.Message]: if messages_with_queues: logger.info(f"About to respond to: ({messages_with_queues})") bodies = [ - schemas.parse_message(json.loads(message.body)) + json.loads(message.body) for message, queue in messages_with_queues ] for body in bodies: From a27f399d38b41dd6dde7607366051b82f82cee37 Mon Sep 17 00:00:00 2001 From: Devin Gaffney Date: Wed, 31 Jul 2024 10:27:46 -0700 Subject: [PATCH 2/5] fix accessors downstream --- lib/queue/processor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/queue/processor.py b/lib/queue/processor.py index 66c6684..5091619 100644 --- a/lib/queue/processor.py +++ b/lib/queue/processor.py @@ -58,10 +58,10 @@ def send_callback(self, message): """ logger.info(f"Message for callback is: {message}") try: - callback_url = message.body.callback_url + callback_url = message.get("body", {}).get("callback_url") response = requests.post( callback_url, - json=message.dict(), + json=message, # headers={"Content-Type": "application/json"}, ) # check for error with the callback From aa8e9016316a985ea076d9a298a1147acf4058a0 Mon Sep 17 00:00:00 2001 From: Devin Gaffney Date: Wed, 31 Jul 2024 10:38:29 -0700 Subject: [PATCH 3/5] fix broken tests --- test/lib/queue/test_processor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/queue/test_processor.py b/test/lib/queue/test_processor.py index 9b5700f..a9f65b1 100644 --- a/test/lib/queue/test_processor.py +++ b/test/lib/queue/test_processor.py @@ -38,14 +38,14 @@ def test_send_callbacks(self): @patch('lib.queue.processor.requests.post') def test_send_callback(self, mock_post): - message_body = schemas.parse_message({"body": {"callback_url": "http://example.com", "text": "This is a test", "id": 123, "result": {"hash_value": [1,2,3]}}, "model_name": "mean_tokens__Model"}) + message_body = {"body": {"callback_url": "http://example.com", "text": "This is a test", "id": 123, "result": {"hash_value": [1,2,3]}}, "model_name": "mean_tokens__Model"} self.queue_processor.send_callback(message_body) mock_post.assert_called_once_with("http://example.com", json=message_body.dict()) @patch('lib.queue.processor.requests.post') def test_send_callback_failure(self, mock_post): mock_post.side_effect = Exception("Request Failed!") - message_body = schemas.parse_message({"body": {"callback_url": "http://example.com", "text": "This is a test", "id": 123, "result": {"hash_value": [1,2,3]}}, "model_name": "mean_tokens__Model"}) + message_body = {"body": {"callback_url": "http://example.com", "text": "This is a test", "id": 123, "result": {"hash_value": [1,2,3]}}, "model_name": "mean_tokens__Model"} with self.assertLogs(level='ERROR') as cm: self.queue_processor.send_callback(message_body) self.assertIn("Failed with Request Failed! on http://example.com with message of", cm.output[0]) From 37437f7e1e695a5805aeb3ce0d7f712879e86928 Mon Sep 17 00:00:00 2001 From: Devin Gaffney Date: Wed, 31 Jul 2024 12:09:49 -0700 Subject: [PATCH 4/5] fix broken tests --- test/lib/queue/test_processor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/queue/test_processor.py b/test/lib/queue/test_processor.py index a9f65b1..c6b5a24 100644 --- a/test/lib/queue/test_processor.py +++ b/test/lib/queue/test_processor.py @@ -40,7 +40,7 @@ def test_send_callbacks(self): def test_send_callback(self, mock_post): message_body = {"body": {"callback_url": "http://example.com", "text": "This is a test", "id": 123, "result": {"hash_value": [1,2,3]}}, "model_name": "mean_tokens__Model"} self.queue_processor.send_callback(message_body) - mock_post.assert_called_once_with("http://example.com", json=message_body.dict()) + mock_post.assert_called_once_with("http://example.com", json=message_body) @patch('lib.queue.processor.requests.post') def test_send_callback_failure(self, mock_post): From 14d7b5e71354be47e4f72c2250114ecc8bf7a491 Mon Sep 17 00:00:00 2001 From: Devin Gaffney Date: Thu, 1 Aug 2024 10:17:49 -0700 Subject: [PATCH 5/5] stringify non string error fields --- lib/model/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/model/model.py b/lib/model/model.py index 0a52217..3e359e2 100644 --- a/lib/model/model.py +++ b/lib/model/model.py @@ -50,7 +50,7 @@ def handle_fingerprinting_error(self, e): if attr == "__traceback__": error_context[attr] = '\n'.join(traceback.format_tb(getattr(e, attr))) else: - error_context[attr] = getattr(e, attr) + error_context[attr] = str(getattr(e, attr)) capture_custom_message("Error during fingerprinting for {self.model_name}", 'info', error_context) return schemas.ErrorResponse(error=str(e), error_details=error_context)