raylim commited on
Commit
e66cef9
·
unverified ·
1 Parent(s): e3bcefe

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

Files changed (1) hide show
  1. 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
- if row["Sex"] not in SEX_OPTIONS and row["Sex"] != "" and row["Sex"] is not None:
 
 
 
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: