From e64e41f65b79bf64371ec7f15a7014e2c832de71 Mon Sep 17 00:00:00 2001 From: Ben Capodanno Date: Mon, 25 Nov 2024 11:30:44 -0800 Subject: [PATCH] Fixed: Unsupported score sets not handled by decorator --- src/dcd_mapping/mavedb_data.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dcd_mapping/mavedb_data.py b/src/dcd_mapping/mavedb_data.py index 831804b..3654eb6 100644 --- a/src/dcd_mapping/mavedb_data.py +++ b/src/dcd_mapping/mavedb_data.py @@ -14,6 +14,7 @@ from typing import Any import requests +from fastapi import HTTPException from pydantic import ValidationError from dcd_mapping.resource_utils import ( @@ -283,8 +284,17 @@ async def wrapper(*args, **kwargs) -> ScoresetMapping: # noqa: ANN002 # Set up metadata and scores for the current run. Now they will be accessible by these functions # without the need to download the data again. temp_dir_as_path = Path(temp_dir) - get_scoreset_metadata(urn, temp_dir_as_path) - get_scoreset_records(urn, silent, temp_dir_as_path) + try: + get_scoreset_metadata(urn, temp_dir_as_path) + get_scoreset_records(urn, silent, temp_dir_as_path) + except ScoresetNotSupportedError as e: + return ScoresetMapping( + metadata=None, + error_message=str(e).strip("'"), + ) + except ResourceAcquisitionError as e: + msg = f"Unable to acquire resource from MaveDB: {e}" + raise HTTPException(status_code=500, detail=msg) from e # Pass the storage path of the temp directory to the wrapped function as a kwarg. kwargs["store_path"] = temp_dir_as_path