Spaces:
Sleeping
Sleeping
Commit
·
c97fddf
1
Parent(s):
72404f0
Fix GitHub token issue
Browse files
app.py
CHANGED
@@ -27,11 +27,12 @@ def upload_directory_to_hf(
|
|
27 |
repo_id: str,
|
28 |
directory: str,
|
29 |
hf_token: str,
|
30 |
-
|
31 |
):
|
|
|
32 |
url = create_repo(
|
33 |
repo_id,
|
34 |
-
token=
|
35 |
exist_ok=True,
|
36 |
repo_type="dataset",
|
37 |
private=private,
|
@@ -42,7 +43,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*",
|
@@ -57,11 +58,7 @@ 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,7 +70,6 @@ def push_to_hf(
|
|
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")
|
|
|
27 |
repo_id: str,
|
28 |
directory: str,
|
29 |
hf_token: str,
|
30 |
+
oauth_token: gr.OAuthToken | None = None,
|
31 |
):
|
32 |
+
private = False
|
33 |
url = create_repo(
|
34 |
repo_id,
|
35 |
+
token=oauth_token.token,
|
36 |
exist_ok=True,
|
37 |
repo_type="dataset",
|
38 |
private=private,
|
|
|
43 |
path_in_repo="data",
|
44 |
repo_id=repo_id,
|
45 |
repo_type="dataset",
|
46 |
+
token=hf_token.token,
|
47 |
commit_message="Migrated from GitHub",
|
48 |
ignore_patterns=[
|
49 |
"*.git*",
|
|
|
58 |
source_github_repository,
|
59 |
destination_hf_hub_repository,
|
60 |
subdirectory,
|
|
|
61 |
):
|
|
|
|
|
|
|
62 |
gr.Info("Cloning source GitHub repository...")
|
63 |
repo, temporary_directory = clone_into_temp_dir(source_github_repository)
|
64 |
gr.Info("Cloning source GitHub repository...Done")
|
|
|
70 |
upload_directory_to_hf(
|
71 |
repo_id=destination_hf_hub_repository,
|
72 |
directory=src_directory,
|
|
|
73 |
private=False,
|
74 |
)
|
75 |
gr.Info("Syncing with Hugging Face Hub...Done")
|