Suzana commited on
Commit
c505c35
·
verified ·
1 Parent(s): ff7a8a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -5,7 +5,6 @@ import os
5
  from pathlib import Path
6
  from huggingface_hub import HfApi, Repository
7
 
8
- # Global DataFrame
9
  df = pd.DataFrame()
10
 
11
  def upload_csv(file):
@@ -14,7 +13,6 @@ def upload_csv(file):
14
  if "text" not in df.columns or "label" not in df.columns:
15
  return gr.update(visible=False), "❌ CSV must contain ‘text’ and ‘label’ columns."
16
  df["label"] = df["label"].fillna("")
17
- # Show the table and set status
18
  return (
19
  gr.update(value=df[["text","label"]], visible=True),
20
  "✅ File uploaded — you can now edit labels."
@@ -51,6 +49,7 @@ def push_to_hub(repo_name: str, hf_token: str) -> str:
51
  repo = Repository(
52
  local_dir=str(local_dir),
53
  clone_from=repo_name,
 
54
  use_auth_token=hf_token
55
  )
56
 
@@ -90,11 +89,9 @@ with gr.Blocks(theme=gr.themes.Default()) as app:
90
  push_btn = gr.Button("🚀 Push")
91
  push_status = gr.Textbox(label="Push Status", interactive=False)
92
 
93
- # Event bindings
94
  upload_btn.click(upload_csv, inputs=file_input, outputs=[df_table, status])
95
- save_btn.click( save_changes, inputs=df_table, outputs=status)
96
  download_btn.click(download_csv, outputs=download_out)
97
  push_btn.click( push_to_hub, inputs=[repo_input, token_input], outputs=push_status)
98
 
99
- # Launch the app
100
  app.launch()
 
5
  from pathlib import Path
6
  from huggingface_hub import HfApi, Repository
7
 
 
8
  df = pd.DataFrame()
9
 
10
  def upload_csv(file):
 
13
  if "text" not in df.columns or "label" not in df.columns:
14
  return gr.update(visible=False), "❌ CSV must contain ‘text’ and ‘label’ columns."
15
  df["label"] = df["label"].fillna("")
 
16
  return (
17
  gr.update(value=df[["text","label"]], visible=True),
18
  "✅ File uploaded — you can now edit labels."
 
49
  repo = Repository(
50
  local_dir=str(local_dir),
51
  clone_from=repo_name,
52
+ repo_type="dataset", # <-- important fix!
53
  use_auth_token=hf_token
54
  )
55
 
 
89
  push_btn = gr.Button("🚀 Push")
90
  push_status = gr.Textbox(label="Push Status", interactive=False)
91
 
 
92
  upload_btn.click(upload_csv, inputs=file_input, outputs=[df_table, status])
93
+ save_btn.click( save_changes, inputs=df_table, outputs=status)
94
  download_btn.click(download_csv, outputs=download_out)
95
  push_btn.click( push_to_hub, inputs=[repo_input, token_input], outputs=push_status)
96
 
 
97
  app.launch()