From b71018df68516fc08f64fc7e14b79bbcadff1373 Mon Sep 17 00:00:00 2001 From: jtyoung84 <104453205+jtyoung84@users.noreply.github.com> Date: Wed, 31 Jan 2024 18:27:38 -0800 Subject: [PATCH] feat: update error message --- src/aind_data_transfer_service/server.py | 8 +++++--- tests/test_server.py | 19 ++++--------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/aind_data_transfer_service/server.py b/src/aind_data_transfer_service/server.py index 74e254a..32a896d 100644 --- a/src/aind_data_transfer_service/server.py +++ b/src/aind_data_transfer_service/server.py @@ -72,7 +72,7 @@ async def validate_csv(request: Request): # Construct hpc job setting most of the vars from the env basic_jobs.append(job.model_dump_json()) except Exception as e: - errors.append(f"{e.__class__}: {e.args}") + errors.append(f"{e.__class__.__name__}{e.args}") message = "There were errors" if len(errors) > 0 else "Valid Data" status_code = 406 if len(errors) > 0 else 200 content = { @@ -106,7 +106,9 @@ async def submit_basic_jobs(request: Request): hpc_job = HpcJobConfigs(basic_upload_job_configs=basic_upload_job) hpc_jobs.append(hpc_job) except Exception as e: - parsing_errors.append(f"Error parsing {job}: {e.__class__}") + parsing_errors.append( + f"Error parsing {job}: {e.__class__.__name__}" + ) if parsing_errors: status_code = 406 message = "There were errors parsing the basic job configs" @@ -126,7 +128,7 @@ async def submit_basic_jobs(request: Request): # Add pause to stagger job requests to the hpc await sleep(0.2) except Exception as e: - logging.error(f"{e.__class__}: {e.args}") + logging.error(f"{e.__class__.__name__}{e.args}") hpc_errors.append( f"Error processing " f"{hpc_job.basic_upload_job_configs.s3_prefix}" diff --git a/tests/test_server.py b/tests/test_server.py index edda731..45595f2 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -192,9 +192,8 @@ def test_submit_jobs_malformed_json( "responses": [], "errors": [ ( - 'Error parsing {"malformed_key": "val"}: ' - "" + 'Error parsing {"malformed_key": "val"}:' + " ValidationError" ) ], }, @@ -230,12 +229,7 @@ def test_validate_malformed_csv(self): response = client.post(url="/api/validate_csv", files=files) self.assertEqual(response.status_code, 406) self.assertEqual( - [ - ( - ":" - " ('Unknown Modality: WRONG_MODALITY_HERE',)" - ) - ], + [("AttributeError('Unknown Modality: WRONG_MODALITY_HERE',)")], response.json()["data"]["errors"], ) @@ -250,12 +244,7 @@ def test_validate_malformed_xlsx(self): response = client.post(url="/api/validate_csv", files=files) self.assertEqual(response.status_code, 406) self.assertEqual( - [ - ( - ":" - " ('Unknown Modality: WRONG_MODALITY_HERE',)" - ) - ], + [("AttributeError('Unknown Modality: WRONG_MODALITY_HERE',)")], response.json()["data"]["errors"], )