luulinh90s commited on
Commit
9c5ef2c
1 Parent(s): 9f88842
Files changed (1) hide show
  1. app.py +11 -18
app.py CHANGED
@@ -17,8 +17,6 @@ if hf_token:
17
  else:
18
  logger.error("HF_TOKEN not found in environment variables")
19
 
20
- SAMPLE_NUM = 10
21
-
22
  # Set up logging
23
  logging.basicConfig(level=logging.INFO,
24
  format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
@@ -79,19 +77,14 @@ def save_session_data(username, data):
79
  with open(temp_file_path, 'w') as f:
80
  f.write(json_data)
81
 
82
- logger.info(f"Data uploaded to Hugging Face Data Space:\n{data}")
83
-
84
- if data['current_index'] < SAMPLE_NUM:
85
- pass
86
- else:
87
- # Upload the file to a separate Hugging Face Space dedicated to data storage
88
- api = HfApi()
89
- api.upload_file(
90
- path_or_fileobj=temp_file_path,
91
- path_in_repo=f"session_data_pref/{file_name}",
92
- repo_id="luulinh90s/Tabular-LLM-Study-Data",
93
- repo_type="space",
94
- )
95
 
96
  # Remove the temporary file
97
  os.remove(temp_file_path)
@@ -158,14 +151,14 @@ def load_samples(methods):
158
 
159
  def select_balanced_samples(samples):
160
  try:
161
- # Ensure we have at least N unique samples
162
  unique_samples = list({(s['category'], s['file']) for s in samples})
163
 
164
- if len(unique_samples) < SAMPLE_NUM:
165
  logger.warning(f"Not enough unique samples. Only {len(unique_samples)} available.")
166
  selected_samples = unique_samples
167
  else:
168
- selected_samples = random.sample(unique_samples, SAMPLE_NUM)
169
 
170
  logger.info(f"Unique sampled samples:\n{selected_samples}")
171
 
 
17
  else:
18
  logger.error("HF_TOKEN not found in environment variables")
19
 
 
 
20
  # Set up logging
21
  logging.basicConfig(level=logging.INFO,
22
  format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
 
77
  with open(temp_file_path, 'w') as f:
78
  f.write(json_data)
79
 
80
+ # Upload the file to a separate Hugging Face Space dedicated to data storage
81
+ api = HfApi()
82
+ api.upload_file(
83
+ path_or_fileobj=temp_file_path,
84
+ path_in_repo=f"session_data_pref/{file_name}",
85
+ repo_id="luulinh90s/Tabular-LLM-Study-Data",
86
+ repo_type="space",
87
+ )
 
 
 
 
 
88
 
89
  # Remove the temporary file
90
  os.remove(temp_file_path)
 
151
 
152
  def select_balanced_samples(samples):
153
  try:
154
+ # Ensure we have at least 10 unique samples
155
  unique_samples = list({(s['category'], s['file']) for s in samples})
156
 
157
+ if len(unique_samples) < 10:
158
  logger.warning(f"Not enough unique samples. Only {len(unique_samples)} available.")
159
  selected_samples = unique_samples
160
  else:
161
+ selected_samples = random.sample(unique_samples, 10)
162
 
163
  logger.info(f"Unique sampled samples:\n{selected_samples}")
164