Spaces:
Sleeping
Sleeping
copilot-swe-agent[bot] raylim commited on
Commit ·
45cb0d2
1
Parent(s): ae3280a
Add error handling for missing tissue site CSV file
Browse filesCo-authored-by: raylim <3074310+raylim@users.noreply.github.com>
- src/mosaic/ui/utils.py +14 -6
src/mosaic/ui/utils.py
CHANGED
|
@@ -37,15 +37,23 @@ def get_tissue_sites():
|
|
| 37 |
"""Get the list of tissue sites from the tissue site map file.
|
| 38 |
|
| 39 |
Returns:
|
| 40 |
-
List of tissue site names
|
| 41 |
"""
|
| 42 |
global tissue_site_list
|
| 43 |
if tissue_site_list is None:
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
return tissue_site_list
|
| 50 |
|
| 51 |
|
|
|
|
| 37 |
"""Get the list of tissue sites from the tissue site map file.
|
| 38 |
|
| 39 |
Returns:
|
| 40 |
+
List of tissue site names. Returns ["Unknown"] if the CSV file is not found.
|
| 41 |
"""
|
| 42 |
global tissue_site_list
|
| 43 |
if tissue_site_list is None:
|
| 44 |
+
try:
|
| 45 |
+
current_dir = Path(__file__).parent.parent.parent.parent
|
| 46 |
+
tissue_site_map_path = current_dir / "data" / "tissue_site_original_to_idx.csv"
|
| 47 |
+
df = pd.read_csv(tissue_site_map_path)
|
| 48 |
+
# Get unique tissue sites and sort them
|
| 49 |
+
tissue_site_list = ["Unknown"] + sorted(df["TISSUE_SITE"].unique().tolist())
|
| 50 |
+
except FileNotFoundError:
|
| 51 |
+
gr.Warning(
|
| 52 |
+
f"Tissue site mapping file not found at {tissue_site_map_path}. "
|
| 53 |
+
"Only 'Unknown' option will be available for tissue site selection. "
|
| 54 |
+
"Please ensure the data files are downloaded from the model repository."
|
| 55 |
+
)
|
| 56 |
+
tissue_site_list = ["Unknown"]
|
| 57 |
return tissue_site_list
|
| 58 |
|
| 59 |
|