eli02 commited on
Commit
851a0e2
·
1 Parent(s): ee42b39

update: Simplify handling of missing columns and remove debug prints in save_reactions_to_dataset function

Browse files
Files changed (1) hide show
  1. app.py +1 -13
app.py CHANGED
@@ -80,28 +80,16 @@ def save_reactions_to_dataset(user_type, username, query, results_mpnet, results
80
  dataset = load_dataset("HumbleBeeAI/al-ghazali-rag-retrieval-evaluation", split="train")
81
  existing_data = dataset.to_dict()
82
 
83
- # Calculate the exact existing length once
84
- existing_length = len(next(iter(existing_data.values())))
85
- print(f"Existing dataset length: {existing_length}")
86
- print(f"New entries to add: {len(data['user_type'])}") # Debug print
87
-
88
  # Handle missing columns
89
  for key in data:
90
  if key not in existing_data:
91
  # Initialize missing columns with exactly existing_length entries
92
- existing_data[key] = ["" if key in ["username", "model_type"] else None] * existing_length
93
 
94
  # Now extend with new data
95
  for key in data:
96
  existing_data[key].extend(data[key])
97
 
98
- # Verify final lengths
99
- final_lengths = {k: len(v) for k, v in existing_data.items()}
100
- print(f"Final lengths of all columns: {final_lengths}") # Debug print
101
-
102
- if len(set(final_lengths.values())) > 1:
103
- raise ValueError(f"Column length mismatch after merging: {final_lengths}")
104
-
105
  except Exception as e:
106
  print(f"Error occurred: {str(e)}")
107
  # If loading fails, start fresh with just the new data
 
80
  dataset = load_dataset("HumbleBeeAI/al-ghazali-rag-retrieval-evaluation", split="train")
81
  existing_data = dataset.to_dict()
82
 
 
 
 
 
 
83
  # Handle missing columns
84
  for key in data:
85
  if key not in existing_data:
86
  # Initialize missing columns with exactly existing_length entries
87
+ existing_data[key] = ["" if key in ["username", "model_type"] else None] * len(next(iter(existing_data.values())))
88
 
89
  # Now extend with new data
90
  for key in data:
91
  existing_data[key].extend(data[key])
92
 
 
 
 
 
 
 
 
93
  except Exception as e:
94
  print(f"Error occurred: {str(e)}")
95
  # If loading fails, start fresh with just the new data