Spaces:
Sleeping
Sleeping
Commit
·
72404f0
1
Parent(s):
541dace
Fix token parameter in upload_directory_to_hf
Browse files
app.py
CHANGED
|
@@ -26,12 +26,12 @@ clone_into_temp_dir("https://github.com/chen-zichen/XplainLLM_dataset/")
|
|
| 26 |
def upload_directory_to_hf(
|
| 27 |
repo_id: str,
|
| 28 |
directory: str,
|
| 29 |
-
hf_token:
|
| 30 |
private: bool = False,
|
| 31 |
):
|
| 32 |
url = create_repo(
|
| 33 |
repo_id,
|
| 34 |
-
token=hf_token
|
| 35 |
exist_ok=True,
|
| 36 |
repo_type="dataset",
|
| 37 |
private=private,
|
|
@@ -42,7 +42,7 @@ def upload_directory_to_hf(
|
|
| 42 |
path_in_repo="data",
|
| 43 |
repo_id=repo_id,
|
| 44 |
repo_type="dataset",
|
| 45 |
-
token=hf_token
|
| 46 |
commit_message="Migrated from GitHub",
|
| 47 |
ignore_patterns=[
|
| 48 |
"*.git*",
|
|
@@ -56,8 +56,12 @@ def upload_directory_to_hf(
|
|
| 56 |
def push_to_hf(
|
| 57 |
source_github_repository,
|
| 58 |
destination_hf_hub_repository,
|
| 59 |
-
subdirectory
|
|
|
|
| 60 |
):
|
|
|
|
|
|
|
|
|
|
| 61 |
gr.Info("Cloning source GitHub repository...")
|
| 62 |
repo, temporary_directory = clone_into_temp_dir(source_github_repository)
|
| 63 |
gr.Info("Cloning source GitHub repository...Done")
|
|
@@ -69,6 +73,7 @@ def push_to_hf(
|
|
| 69 |
upload_directory_to_hf(
|
| 70 |
repo_id=destination_hf_hub_repository,
|
| 71 |
directory=src_directory,
|
|
|
|
| 72 |
private=False,
|
| 73 |
)
|
| 74 |
gr.Info("Syncing with Hugging Face Hub...Done")
|
|
|
|
| 26 |
def upload_directory_to_hf(
|
| 27 |
repo_id: str,
|
| 28 |
directory: str,
|
| 29 |
+
hf_token: str,
|
| 30 |
private: bool = False,
|
| 31 |
):
|
| 32 |
url = create_repo(
|
| 33 |
repo_id,
|
| 34 |
+
token=hf_token,
|
| 35 |
exist_ok=True,
|
| 36 |
repo_type="dataset",
|
| 37 |
private=private,
|
|
|
|
| 42 |
path_in_repo="data",
|
| 43 |
repo_id=repo_id,
|
| 44 |
repo_type="dataset",
|
| 45 |
+
token=hf_token,
|
| 46 |
commit_message="Migrated from GitHub",
|
| 47 |
ignore_patterns=[
|
| 48 |
"*.git*",
|
|
|
|
| 56 |
def push_to_hf(
|
| 57 |
source_github_repository,
|
| 58 |
destination_hf_hub_repository,
|
| 59 |
+
subdirectory,
|
| 60 |
+
hf_token: gr.OAuthToken,
|
| 61 |
):
|
| 62 |
+
if not hf_token:
|
| 63 |
+
raise gr.Error("You need to login to use this Space")
|
| 64 |
+
token = hf_token.token
|
| 65 |
gr.Info("Cloning source GitHub repository...")
|
| 66 |
repo, temporary_directory = clone_into_temp_dir(source_github_repository)
|
| 67 |
gr.Info("Cloning source GitHub repository...Done")
|
|
|
|
| 73 |
upload_directory_to_hf(
|
| 74 |
repo_id=destination_hf_hub_repository,
|
| 75 |
directory=src_directory,
|
| 76 |
+
hf_token=token,
|
| 77 |
private=False,
|
| 78 |
)
|
| 79 |
gr.Info("Syncing with Hugging Face Hub...Done")
|