multimodalart HF staff commited on
Commit
ab6eb3e
·
1 Parent(s): cf87d85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -126,6 +126,7 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], url, progress=gr.Prog
126
  os.makedirs(folder, exist_ok=False)
127
  info, downloaded_files = process_url(url, folder)
128
  create_readme(info, downloaded_files, folder)
 
129
  try:
130
  api = HfApi(token=os.environ["HUGGING_FACE_HUB_TOKEN"])
131
  username = api.whoami()["name"]
@@ -142,14 +143,14 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], url, progress=gr.Prog
142
  response_code = transfer_repos(repo_id, user_repo_id)
143
  print("response_code", response_code)
144
  i = 0
145
- while response_code != 200:
146
- if response_code == 404:
147
  raise gr.Error("Something went wrong with the model upload. Try again.")
148
- elif response_code == 409 and i < 3:
149
  user_repo_id = f"{profile.preferred_username}/{slug_name}-{i}"
150
  response_code = transfer_repos(repo_id, user_repo_id)
151
  i += 1
152
- elif response_code == 409 and i >= 3:
153
  raise gr.Error("It seems this model has been uploaded already in your account.")
154
  else:
155
  raise gr.Error(f"Unexpected response code: {response_code}.")
 
126
  os.makedirs(folder, exist_ok=False)
127
  info, downloaded_files = process_url(url, folder)
128
  create_readme(info, downloaded_files, folder)
129
+ print(os.listdir(folder))
130
  try:
131
  api = HfApi(token=os.environ["HUGGING_FACE_HUB_TOKEN"])
132
  username = api.whoami()["name"]
 
143
  response_code = transfer_repos(repo_id, user_repo_id)
144
  print("response_code", response_code)
145
  i = 0
146
+ while response_code != "200":
147
+ if response_code == "404":
148
  raise gr.Error("Something went wrong with the model upload. Try again.")
149
+ elif response_code == "409" and i < 3:
150
  user_repo_id = f"{profile.preferred_username}/{slug_name}-{i}"
151
  response_code = transfer_repos(repo_id, user_repo_id)
152
  i += 1
153
+ elif response_code == "409" and i >= 3:
154
  raise gr.Error("It seems this model has been uploaded already in your account.")
155
  else:
156
  raise gr.Error(f"Unexpected response code: {response_code}.")