MarcosRodrigo commited on
Commit
ad7507a
·
verified ·
1 Parent(s): be5a0d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -81,9 +81,17 @@ def load_history():
81
  def save_summary_to_history():
82
  timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
83
  history_filename = f"{HISTORY_DIR}/{timestamp}.txt"
 
 
 
 
 
 
84
  if os.path.exists(TEMP_FILE):
85
  summary_df = pd.read_csv(TEMP_FILE)
86
  summary_df.to_csv(history_filename, index=False)
 
 
87
  upload_file(path_or_fileobj=history_filename, path_in_repo=history_filename, repo_id=REPO_ID, token=hf_token, repo_type="space")
88
  return timestamp
89
 
 
81
  def save_summary_to_history():
82
  timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
83
  history_filename = f"{HISTORY_DIR}/{timestamp}.txt"
84
+
85
+ # Ensure the history directory exists
86
+ if not os.path.exists(HISTORY_DIR):
87
+ os.makedirs(HISTORY_DIR)
88
+
89
+ # Read the current selections file
90
  if os.path.exists(TEMP_FILE):
91
  summary_df = pd.read_csv(TEMP_FILE)
92
  summary_df.to_csv(history_filename, index=False)
93
+
94
+ # Upload the file to the repository
95
  upload_file(path_or_fileobj=history_filename, path_in_repo=history_filename, repo_id=REPO_ID, token=hf_token, repo_type="space")
96
  return timestamp
97