Omnibus commited on
Commit
de74fd4
·
1 Parent(s): bf4ee32

Create hf_system.py

Browse files
Files changed (1) hide show
  1. hf_system.py +24 -0
hf_system.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import HfApi,upload_file,file_exists
2
+
3
+ def create_repo():
4
+ return None
5
+
6
+ def file_exists(repo_id,file_name,repo_type):
7
+ if file_exists(repo_id, file_name,repo_type):
8
+ return f"File:: {file_name} exists in {repo_id}"
9
+ else:
10
+ return f"File:: {file_name} does not exist in {repo_id}"
11
+
12
+ def hf_upload(file_obj,repo_file,repo_id,token,repo_type="space")
13
+ api=HfApi()
14
+ try:
15
+ api.upload_file(
16
+ path_or_fileobj=file_obj,
17
+ path_in_repo=repo_file,
18
+ repo_id=repo_id,
19
+ token=token,
20
+ repo_type=repo_type,
21
+ )
22
+ return f"File written to {repo_id}/{repo_file}"
23
+ except Exception as e:
24
+ return e