Spaces:
Sleeping
Sleeping
Commit
·
d88bb9d
1
Parent(s):
138d0d5
better secret handling
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def assign_samples(csv_path):
|
|
27 |
def load_existing_annotations():
|
28 |
"""Load the existing annotations from the HF dataset."""
|
29 |
try:
|
30 |
-
file_path = hf_hub_download(HF_REPO, CSV_FILENAME, repo_type="dataset")
|
31 |
return pd.read_csv(file_path)
|
32 |
except Exception:
|
33 |
return pd.DataFrame(columns=["username", "id"]) # Return empty DataFrame if not found
|
@@ -72,8 +72,8 @@ if dataset.empty:
|
|
72 |
def push_to_hf_hub(csv_path):
|
73 |
api = HfApi()
|
74 |
try:
|
75 |
-
api.create_repo(HF_REPO, repo_type="dataset", exist_ok=True)
|
76 |
-
api.upload_file(path_or_fileobj=csv_path, path_in_repo=CSV_FILENAME, repo_id=HF_REPO, repo_type="dataset")
|
77 |
print(f"Dataset updated: https://huggingface.co/datasets/{HF_REPO}")
|
78 |
except Exception as e:
|
79 |
print(f"Error pushing to HF: {e}")
|
|
|
27 |
def load_existing_annotations():
|
28 |
"""Load the existing annotations from the HF dataset."""
|
29 |
try:
|
30 |
+
file_path = hf_hub_download(HF_REPO, CSV_FILENAME, repo_type="dataset", token=st.secrets["HF_TOKEN"])
|
31 |
return pd.read_csv(file_path)
|
32 |
except Exception:
|
33 |
return pd.DataFrame(columns=["username", "id"]) # Return empty DataFrame if not found
|
|
|
72 |
def push_to_hf_hub(csv_path):
|
73 |
api = HfApi()
|
74 |
try:
|
75 |
+
api.create_repo(HF_REPO, repo_type="dataset", exist_ok=True, token=st.secrets["HF_TOKEN"])
|
76 |
+
api.upload_file(path_or_fileobj=csv_path, path_in_repo=CSV_FILENAME, repo_id=HF_REPO, repo_type="dataset", token=st.secrets["HF_TOKEN"])
|
77 |
print(f"Dataset updated: https://huggingface.co/datasets/{HF_REPO}")
|
78 |
except Exception as e:
|
79 |
print(f"Error pushing to HF: {e}")
|