Spaces:
Running
Running
File size: 847 Bytes
0d13157 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | from huggingface_hub import upload_folder
from huggingface_hub import HfApi
from huggingface_hub import login
import os
from pathlib import Path
import sys
class DatasetHandler():
def __init__(self,hf_token):
login(hf_token)
self.api = HfApi(token = hf_token)
def upload_dump(self,path,name):
try:
upload_folder(folder_path=path,path_in_repo=name, repo_id="ProjectFrozone/MongoDBDumps", repo_type="dataset")
return 0
except:
return 1
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python3 dump_handler.py file_path name")
raise Exception()
file_path = sys.argv[1]
name = sys.argv[2]
token = os.getenv("HF_TOKEN")
handler = DatasetHandler(token)
try:
handler.upload_dump(file_path,name)
except:
print("Problem In Upload")
|