Site / src /dump_handler.py
GalaxyTab's picture
Started working on dumping the database
0d13157
raw
history blame contribute delete
847 Bytes
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")