raylim commited on
Commit
6bb43ff
·
unverified ·
1 Parent(s): 96e060d

Handle legacy 'Unknown' sex values gracefully

Browse files

- Silently convert 'Unknown' to empty string in validation
- Handle 'Unknown' in update_settings_column function
- Prevents 'Unknown is not in choices' error from Gradio
- Update uv.lock for Python version constraint
- Users will need to manually select Male/Female for analysis

Files changed (3) hide show
  1. src/mosaic/ui/app.py +3 -0
  2. src/mosaic/ui/utils.py +4 -1
  3. uv.lock +0 -0
src/mosaic/ui/app.py CHANGED
@@ -433,6 +433,9 @@ def launch_gradio(server_name, server_port, share):
433
  # Convert None to empty string for display (especially for Sex column)
434
  if new_value is None:
435
  new_value = ""
 
 
 
436
  updated_df[column_name] = new_value
437
  return updated_df
438
 
 
433
  # Convert None to empty string for display (especially for Sex column)
434
  if new_value is None:
435
  new_value = ""
436
+ # Convert legacy "Unknown" sex values to empty string
437
+ if column_name == "Sex" and new_value == "Unknown":
438
+ new_value = ""
439
  updated_df[column_name] = new_value
440
  return updated_df
441
 
src/mosaic/ui/utils.py CHANGED
@@ -183,8 +183,11 @@ def validate_settings(
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
  )
 
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
+ # Convert old "Unknown" values to empty string silently
187
  sex_value = row["Sex"]
188
+ if sex_value == "Unknown":
189
+ settings_df.at[idx, "Sex"] = ""
190
+ elif sex_value and sex_value not in SEX_OPTIONS:
191
  warnings.append(
192
  f"Slide {slide_name}: Invalid sex value '{sex_value}'. Valid options are: {', '.join(SEX_OPTIONS)}. "
193
  )
uv.lock CHANGED
The diff for this file is too large to render. See raw diff