Update utils.py
Browse files
utils.py
CHANGED
@@ -103,8 +103,7 @@ api = HfApi()
|
|
103 |
|
104 |
|
105 |
|
106 |
-
|
107 |
-
login(token=hf_token)
|
108 |
|
109 |
# API-Instanz erstellen
|
110 |
api = HfApi()
|
@@ -516,7 +515,9 @@ def load_split_to_original_mapping(directory="chroma/kkg", filename="mapping.pkl
|
|
516 |
|
517 |
|
518 |
|
519 |
-
|
|
|
|
|
520 |
# Beispiel-Upload-Funktion
|
521 |
def upload_file_to_huggingface(file_path, upload_path):
|
522 |
api.upload_file(
|
@@ -527,14 +528,11 @@ def upload_file_to_huggingface(file_path, upload_path):
|
|
527 |
token=HF_WRITE
|
528 |
)
|
529 |
|
530 |
-
|
531 |
-
# Dokumente aus anderem Space laden
|
532 |
-
#######################################
|
533 |
#ein File aus dem Space mit der REPO_ID laden
|
534 |
def download_file_from_hf(file_name, save_path):
|
535 |
url = f"https://huggingface.co/{STORAGE_REPO_ID}/resolve/main/{file_name}"
|
536 |
-
|
537 |
-
response = requests.get(url, headers=headers)
|
538 |
response.raise_for_status() # Raise an error for bad status codes
|
539 |
with open(save_path, 'wb') as file:
|
540 |
file.write(response.content)
|
|
|
103 |
|
104 |
|
105 |
|
106 |
+
HfFolder.save_token(hf_token)
|
|
|
107 |
|
108 |
# API-Instanz erstellen
|
109 |
api = HfApi()
|
|
|
515 |
|
516 |
|
517 |
|
518 |
+
#######################################
|
519 |
+
# Dokumente aus anderem Space laden und speichern
|
520 |
+
#######################################
|
521 |
# Beispiel-Upload-Funktion
|
522 |
def upload_file_to_huggingface(file_path, upload_path):
|
523 |
api.upload_file(
|
|
|
528 |
token=HF_WRITE
|
529 |
)
|
530 |
|
531 |
+
|
|
|
|
|
532 |
#ein File aus dem Space mit der REPO_ID laden
|
533 |
def download_file_from_hf(file_name, save_path):
|
534 |
url = f"https://huggingface.co/{STORAGE_REPO_ID}/resolve/main/{file_name}"
|
535 |
+
response = requests.get(url, headers=HEADERS)
|
|
|
536 |
response.raise_for_status() # Raise an error for bad status codes
|
537 |
with open(save_path, 'wb') as file:
|
538 |
file.write(response.content)
|