joaomorossini commited on
Commit
1ada7a5
1 Parent(s): 1cc2d9a

Reverting problematic commit 'update download functionality to work in HF Spaces'

Browse files

This reverts commit 34c3ae032a4194df06ed5eac75c9b58187627257.

Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import re
2
  import os
3
- from io import BytesIO
4
  from dotenv import load_dotenv
5
 
6
  import gradio as gr
@@ -24,14 +23,17 @@ logs_df = PandasDataFrame(columns=logs_columns)
24
 
25
  def download_logs():
26
  global logs_df
 
 
 
 
 
27
 
28
- # Convert the DataFrame into a CSV byte stream
29
- output = BytesIO()
30
- logs_df.to_csv(output, index=False)
31
- output.seek(0) # Rewind the buffer
32
 
33
- # Return the CSV byte stream and filename for Gradio to generate a download link
34
- return output, "classification_logs.csv"
35
 
36
 
37
  def build_context(row):
 
1
  import re
2
  import os
 
3
  from dotenv import load_dotenv
4
 
5
  import gradio as gr
 
23
 
24
  def download_logs():
25
  global logs_df
26
+ # Check for the current operating system's desktop path
27
+ if os.name == 'nt': # For Windows
28
+ desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')
29
+ else: # For macOS and Linux
30
+ desktop = os.path.join(os.path.join(os.path.expanduser('~')), 'Desktop')
31
 
32
+ # Define the path to save the CSV file on the desktop
33
+ file_path = os.path.join(desktop, 'classification_logs.csv')
 
 
34
 
35
+ # Save the DataFrame to the CSV file on the desktop
36
+ logs_df.to_csv(file_path)
37
 
38
 
39
  def build_context(row):