Functions / hf_system.py
Omnibus's picture
Create hf_system.py
de74fd4
raw
history blame contribute delete
727 Bytes
from huggingface_hub import HfApi,upload_file,file_exists
def create_repo():
return None
def file_exists(repo_id,file_name,repo_type):
if file_exists(repo_id, file_name,repo_type):
return f"File:: {file_name} exists in {repo_id}"
else:
return f"File:: {file_name} does not exist in {repo_id}"
def hf_upload(file_obj,repo_file,repo_id,token,repo_type="space")
api=HfApi()
try:
api.upload_file(
path_or_fileobj=file_obj,
path_in_repo=repo_file,
repo_id=repo_id,
token=token,
repo_type=repo_type,
)
return f"File written to {repo_id}/{repo_file}"
except Exception as e:
return e