Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
@@ -9,14 +9,15 @@ from huggingface_hub import Repository, HfApi
|
|
9 |
import os
|
10 |
tqdm.pandas()
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
endpoint="https://huggingface.co/spaces/Add1E/SpotifyHitPrediction",
|
15 |
-
token=os.getenv("token")
|
16 |
-
)
|
17 |
|
18 |
-
#
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
def predict_popularity(features, trainset):
|
22 |
predictions = [None] * 2
|
@@ -33,7 +34,7 @@ def addToCsvAndTrain(trainset):
|
|
33 |
]
|
34 |
neues_df = pd.DataFrame(trainset, columns= data.columns)
|
35 |
df = pd.concat([data, neues_df], ignore_index=True)
|
36 |
-
df.to_csv('
|
37 |
repo.git_add('top50.csv')
|
38 |
repo.git_commit("Add top50.csv")
|
39 |
repo.git_push()
|
|
|
9 |
import os
|
10 |
tqdm.pandas()
|
11 |
|
12 |
+
api = HfApi()
|
13 |
+
token = HfFolder.get_token() # Das Token wird aus den Hugging Face Secrets abgerufen
|
|
|
|
|
|
|
14 |
|
15 |
+
# Überprüfen, ob das Token vorhanden ist
|
16 |
+
if token is None:
|
17 |
+
raise ValueError("Hugging Face API-Token ist nicht gesetzt.")
|
18 |
+
|
19 |
+
# Klonen Sie das Repository (dies wird in Ihrem Space ausgeführt)
|
20 |
+
repo = Repository(local_dir="SpotifyHitPrediction", clone_from="Add1E/SpotifyHitPrediction", use_auth_token=token)
|
21 |
|
22 |
def predict_popularity(features, trainset):
|
23 |
predictions = [None] * 2
|
|
|
34 |
]
|
35 |
neues_df = pd.DataFrame(trainset, columns= data.columns)
|
36 |
df = pd.concat([data, neues_df], ignore_index=True)
|
37 |
+
df.to_csv('top50.csv', index=False)
|
38 |
repo.git_add('top50.csv')
|
39 |
repo.git_commit("Add top50.csv")
|
40 |
repo.git_push()
|