John6666 commited on
Commit
5870f39
1 Parent(s): 32e0736

Upload t2i_space.py

Browse files
Files changed (1) hide show
  1. 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 as e:
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
- space_secrets=[{"key": "HF_TOKEN", "value": token}] if is_setkey else [{"key": "HF_TOKEN", "value": ""}])
 
 
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,