multimodalart HF staff commited on
Commit
7950bc5
1 Parent(s): aac3460

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -289,12 +289,15 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], url, link_civit=False
289
  folder = str(uuid.uuid4())
290
  os.makedirs(folder, exist_ok=False)
291
  info, downloaded_files = process_url(url, profile, folder=folder)
292
- user_repo_id = f"{profile.preferred_username}/{slug_name}"
293
- create_readme(info, downloaded_files, user_repo_id, link_civit, folder=folder)
294
  try:
295
  api = HfApi(token=os.environ["HUGGING_FACE_HUB_TOKEN"])
296
  username = api.whoami()["name"]
297
  slug_name = slugify(info["name"])
 
 
 
 
 
298
  repo_id = f"{username}/{profile.preferred_username}-{slug_name}"
299
  api.create_repo(repo_id=repo_id, private=True, exist_ok=True)
300
  api.upload_folder(
@@ -304,7 +307,7 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], url, link_civit=False
304
  )
305
  api.update_repo_visibility(repo_id=repo_id, private=False)
306
  except:
307
- raise gr.Error("something went wrong")
308
 
309
  transfer_repos = gr.load("multimodalart/transfer_repos", hf_token=os.environ["HUGGING_FACE_HUB_TOKEN"], src="spaces")
310
 
 
289
  folder = str(uuid.uuid4())
290
  os.makedirs(folder, exist_ok=False)
291
  info, downloaded_files = process_url(url, profile, folder=folder)
 
 
292
  try:
293
  api = HfApi(token=os.environ["HUGGING_FACE_HUB_TOKEN"])
294
  username = api.whoami()["name"]
295
  slug_name = slugify(info["name"])
296
+ except:
297
+ raise gr.Error("logging into hf went wrong")
298
+ user_repo_id = f"{profile.preferred_username}/{slug_name}"
299
+ create_readme(info, downloaded_files, user_repo_id, link_civit, folder=folder)
300
+ try:
301
  repo_id = f"{username}/{profile.preferred_username}-{slug_name}"
302
  api.create_repo(repo_id=repo_id, private=True, exist_ok=True)
303
  api.upload_folder(
 
307
  )
308
  api.update_repo_visibility(repo_id=repo_id, private=False)
309
  except:
310
+ raise gr.Error("uploading the repo went wrong")
311
 
312
  transfer_repos = gr.load("multimodalart/transfer_repos", hf_token=os.environ["HUGGING_FACE_HUB_TOKEN"], src="spaces")
313