Jesse Liu commited on
Commit
6d366b8
·
1 Parent(s): 3895244

Sync latest app + data (clinician groups, jsonl)

Browse files
Files changed (1) hide show
  1. chatgpt.py +13 -1
chatgpt.py CHANGED
@@ -786,11 +786,16 @@ with gr.Blocks() as app:
786
  jsonl_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Qwen__Qwen2.5-7B-Instruct_io.jsonl')
787
  jsonl_loaded = False
788
  eval_data_by_patient = {} # Initialize empty to ensure clean start
 
 
789
  if os.path.exists(jsonl_path):
 
790
  print(f"Loading data from JSONL: {jsonl_path}")
791
  jsonl_data = load_jsonl(jsonl_path)
792
  print(f"Found {len(jsonl_data)} entries in JSONL file")
 
793
  for entry in jsonl_data:
 
794
  full_id = entry.get('patient_id', '') or ''
795
  # Extract patient_id from format like "11318742_admission_29646478_input"
796
  # Only keep the patient_id part (e.g., "11318742")
@@ -830,8 +835,11 @@ with gr.Blocks() as app:
830
  'highlights': []
831
  }
832
  jsonl_loaded = True
833
- print(f"Loaded {len(eval_data_by_patient)} patients from JSONL")
 
834
  print(f"Patient IDs: {sorted(list(eval_data_by_patient.keys()))}")
 
 
835
  else:
836
  print(f"[WARNING] JSONL file not found: {jsonl_path}")
837
  print(f"[WARNING] Will attempt to load from fallback sources")
@@ -839,7 +847,9 @@ with gr.Blocks() as app:
839
  # Fallback to old format if JSONL not found
840
  # IMPORTANT: Only load from fallback if JSONL was NOT loaded
841
  if (not jsonl_loaded) and os.path.exists(summaries_dir):
 
842
  print(f"[INFO] Loading from fallback summaries_dir: {summaries_dir}")
 
843
  files = os.listdir(summaries_dir)
844
  pattern = re.compile(r"^subject_(\d+)_hadm_(\d+)_(model_input|summary)\.txt$")
845
  for fname in files:
@@ -889,8 +899,10 @@ with gr.Blocks() as app:
889
  # IMPORTANT: Only load if JSONL was NOT loaded (to avoid duplicate patients)
890
  per_adm_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'per_admission_results_30patient_2ad')
891
  if (not jsonl_loaded) and os.path.exists(per_adm_dir):
 
892
  print(f"[WARNING] JSONL not loaded, falling back to per_admission_results_30patient_2ad directory")
893
  print(f"[WARNING] This should NOT happen if Qwen JSONL exists!")
 
894
  for fname in os.listdir(per_adm_dir):
895
  if not fname.startswith('patient_') or not fname.endswith('.json') or fname == 'all_patients_per_admission.json':
896
  continue
 
786
  jsonl_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Qwen__Qwen2.5-7B-Instruct_io.jsonl')
787
  jsonl_loaded = False
788
  eval_data_by_patient = {} # Initialize empty to ensure clean start
789
+
790
+ # FORCE: Only load from Qwen JSONL, completely skip all other data sources
791
  if os.path.exists(jsonl_path):
792
+ print(f"[INFO] ========== LOADING FROM QWEN JSONL ONLY ==========")
793
  print(f"Loading data from JSONL: {jsonl_path}")
794
  jsonl_data = load_jsonl(jsonl_path)
795
  print(f"Found {len(jsonl_data)} entries in JSONL file")
796
+ entry_count = 0
797
  for entry in jsonl_data:
798
+ entry_count += 1
799
  full_id = entry.get('patient_id', '') or ''
800
  # Extract patient_id from format like "11318742_admission_29646478_input"
801
  # Only keep the patient_id part (e.g., "11318742")
 
835
  'highlights': []
836
  }
837
  jsonl_loaded = True
838
+ print(f"Processed {entry_count} entries from JSONL")
839
+ print(f"Loaded {len(eval_data_by_patient)} unique patients from JSONL")
840
  print(f"Patient IDs: {sorted(list(eval_data_by_patient.keys()))}")
841
+ print(f"[INFO] JSONL loading complete. jsonl_loaded = {jsonl_loaded}")
842
+ print(f"[INFO] ================================================")
843
  else:
844
  print(f"[WARNING] JSONL file not found: {jsonl_path}")
845
  print(f"[WARNING] Will attempt to load from fallback sources")
 
847
  # Fallback to old format if JSONL not found
848
  # IMPORTANT: Only load from fallback if JSONL was NOT loaded
849
  if (not jsonl_loaded) and os.path.exists(summaries_dir):
850
+ print(f"[WARNING] ========== FALLBACK: Loading from summaries_dir ==========")
851
  print(f"[INFO] Loading from fallback summaries_dir: {summaries_dir}")
852
+ print(f"[WARNING] This should NOT happen if Qwen JSONL exists!")
853
  files = os.listdir(summaries_dir)
854
  pattern = re.compile(r"^subject_(\d+)_hadm_(\d+)_(model_input|summary)\.txt$")
855
  for fname in files:
 
899
  # IMPORTANT: Only load if JSONL was NOT loaded (to avoid duplicate patients)
900
  per_adm_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'per_admission_results_30patient_2ad')
901
  if (not jsonl_loaded) and os.path.exists(per_adm_dir):
902
+ print(f"[WARNING] ========== FALLBACK: Loading from per_admission_results_30patient_2ad ==========")
903
  print(f"[WARNING] JSONL not loaded, falling back to per_admission_results_30patient_2ad directory")
904
  print(f"[WARNING] This should NOT happen if Qwen JSONL exists!")
905
+ print(f"[WARNING] jsonl_loaded flag = {jsonl_loaded}")
906
  for fname in os.listdir(per_adm_dir):
907
  if not fname.startswith('patient_') or not fname.endswith('.json') or fname == 'all_patients_per_admission.json':
908
  continue