Spaces:
Sleeping
Sleeping
Fix premature sex validation warnings
Browse files- Only warn about invalid sex values (not Male/Female), not empty/None
- Empty or None sex values will be validated at analysis time
- Prevents annoying warnings when settings are first created
- Improve warning message to show the invalid value
- src/mosaic/ui/utils.py +5 -2
src/mosaic/ui/utils.py
CHANGED
|
@@ -181,9 +181,12 @@ def validate_settings(
|
|
| 181 |
f"Slide {slide_name}: Unknown site type. Valid types are: Metastatic, Primary. "
|
| 182 |
)
|
| 183 |
settings_df.at[idx, "Site Type"] = "Primary"
|
| 184 |
-
|
|
|
|
|
|
|
|
|
|
| 185 |
warnings.append(
|
| 186 |
-
f"Slide {slide_name}: Invalid sex value. Valid options are: {', '.join(SEX_OPTIONS)}. "
|
| 187 |
)
|
| 188 |
settings_df.at[idx, "Sex"] = ""
|
| 189 |
if row["Tissue Site"] not in tissue_sites:
|
|
|
|
| 181 |
f"Slide {slide_name}: Unknown site type. Valid types are: Metastatic, Primary. "
|
| 182 |
)
|
| 183 |
settings_df.at[idx, "Site Type"] = "Primary"
|
| 184 |
+
# Only warn about invalid sex values that are not empty/None
|
| 185 |
+
# Empty/None will be validated at analysis time
|
| 186 |
+
sex_value = row["Sex"]
|
| 187 |
+
if sex_value and sex_value not in SEX_OPTIONS:
|
| 188 |
warnings.append(
|
| 189 |
+
f"Slide {slide_name}: Invalid sex value '{sex_value}'. Valid options are: {', '.join(SEX_OPTIONS)}. "
|
| 190 |
)
|
| 191 |
settings_df.at[idx, "Sex"] = ""
|
| 192 |
if row["Tissue Site"] not in tissue_sites:
|