Spaces:
Sleeping
Sleeping
Upload t2i_space.py
Browse files- t2i_space.py +5 -3
t2i_space.py
CHANGED
@@ -12,7 +12,7 @@ def is_repo_name(s):
|
|
12 |
def get_token():
|
13 |
try:
|
14 |
token = HfFolder.get_token()
|
15 |
-
except Exception
|
16 |
token = ""
|
17 |
return token
|
18 |
|
@@ -65,8 +65,10 @@ def upload_to_space(repo_id: str, paths: list[str], is_private: bool, is_setkey:
|
|
65 |
try:
|
66 |
# Create the repo if it does not exist
|
67 |
if not is_repo_exists(repo_id):
|
68 |
-
create_repo(repo_id, repo_type="space", space_sdk="gradio", token=token, private=is_private,
|
69 |
-
|
|
|
|
|
70 |
# Upload files to the repository
|
71 |
operations = [CommitOperationAdd(path_in_repo=Path(p).name, path_or_fileobj=p) for p in paths]
|
72 |
api.create_commit(repo_id=repo_id, repo_type="space", operations=operations,
|
|
|
12 |
def get_token():
|
13 |
try:
|
14 |
token = HfFolder.get_token()
|
15 |
+
except Exception:
|
16 |
token = ""
|
17 |
return token
|
18 |
|
|
|
65 |
try:
|
66 |
# Create the repo if it does not exist
|
67 |
if not is_repo_exists(repo_id):
|
68 |
+
if is_setkey: create_repo(repo_id, repo_type="space", space_sdk="gradio", token=token, private=is_private,
|
69 |
+
space_secrets=[{"key": "HF_TOKEN", "value": token}])
|
70 |
+
else: create_repo(repo_id, repo_type="space", space_sdk="gradio", token=token, private=is_private)
|
71 |
+
|
72 |
# Upload files to the repository
|
73 |
operations = [CommitOperationAdd(path_in_repo=Path(p).name, path_or_fileobj=p) for p in paths]
|
74 |
api.create_commit(repo_id=repo_id, repo_type="space", operations=operations,
|