Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
from pathlib import Path
|
4 |
-
from huggingface_hub import whoami, HfApi, hf_hub_download
|
5 |
from huggingface_hub.utils import build_hf_headers, hf_raise_for_status
|
6 |
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
7 |
|
@@ -26,9 +26,9 @@ def duplicate(source_repo, dst_repo, repo_type, private, overwrite, oauth_token:
|
|
26 |
file = hf_hub_download(repo_id=source_repo, filename=path, repo_type=repo_type, token=hf_token)
|
27 |
if not Path(file).exists(): continue
|
28 |
if Path(file).is_dir():
|
29 |
-
api.upload_folder(repo_id=dst_repo, folder_path=file, path_in_repo=
|
30 |
elif Path(file).is_file():
|
31 |
-
api.upload_file(repo_id=dst_repo, path_or_fileobj=file, path_in_repo=
|
32 |
Path(file).unlink()
|
33 |
if repo_type == "dataset": repo_url = f"https://huggingface.co/datasets/{dst_repo}"
|
34 |
elif repo_type == "space": repo_url = f"https://huggingface.co/spaces/{dst_repo}"
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
from pathlib import Path
|
4 |
+
from huggingface_hub import whoami, HfApi, hf_hub_download
|
5 |
from huggingface_hub.utils import build_hf_headers, hf_raise_for_status
|
6 |
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
7 |
|
|
|
26 |
file = hf_hub_download(repo_id=source_repo, filename=path, repo_type=repo_type, token=hf_token)
|
27 |
if not Path(file).exists(): continue
|
28 |
if Path(file).is_dir():
|
29 |
+
api.upload_folder(repo_id=dst_repo, folder_path=file, path_in_repo=path, repo_type=repo_type, token=hf_token)
|
30 |
elif Path(file).is_file():
|
31 |
+
api.upload_file(repo_id=dst_repo, path_or_fileobj=file, path_in_repo=path, repo_type=repo_type, token=hf_token)
|
32 |
Path(file).unlink()
|
33 |
if repo_type == "dataset": repo_url = f"https://huggingface.co/datasets/{dst_repo}"
|
34 |
elif repo_type == "space": repo_url = f"https://huggingface.co/spaces/{dst_repo}"
|