multimodalart HF staff commited on
Commit
78503b1
1 Parent(s): 277c607

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -297,26 +297,28 @@ def upload_civit_to_hf(profile: Optional[gr.OAuthProfile], oauth_token: gr.OAuth
297
  folder = str(uuid.uuid4())
298
  os.makedirs(folder, exist_ok=False)
299
  info, downloaded_files = process_url(url, profile, folder=folder)
300
- try:
301
  #print(oauth_token)
302
  #print(oauth_token.token)
303
- #api = HfApi(token=oauth_token.token)
304
- username = whoami(oauth_token.token)["name"]
305
- slug_name = slugify(info["name"])
306
- except:
307
- raise gr.Error("logging into hf went wrong")
 
308
  user_repo_id = f"{profile.username}/{slug_name}"
309
  create_readme(info, downloaded_files, user_repo_id, link_civit, folder=folder)
310
  try:
311
  #repo_id = f"{username}/{profile.preferred_username}-{slug_name}"
312
  print("Creating repo...")
313
  print(user_repo_id)
314
- create_repo(repo_id=user_repo_id, private=False, exist_ok=True)
315
  print("Uploading repo...")
316
  upload_folder(
317
  folder_path=folder,
318
  repo_id=user_repo_id,
319
  repo_type="model",
 
320
  )
321
  print("Changing repo visibility...")
322
  #api.update_repo_visibility(repo_id=user_repo_id, private=False)
 
297
  folder = str(uuid.uuid4())
298
  os.makedirs(folder, exist_ok=False)
299
  info, downloaded_files = process_url(url, profile, folder=folder)
300
+ #try:
301
  #print(oauth_token)
302
  #print(oauth_token.token)
303
+ #api = HfApi()
304
+
305
+ #except:
306
+ # raise gr.Error("logging into hf went wrong")
307
+ username = {profile.username}
308
+ slug_name = slugify(info["name"])
309
  user_repo_id = f"{profile.username}/{slug_name}"
310
  create_readme(info, downloaded_files, user_repo_id, link_civit, folder=folder)
311
  try:
312
  #repo_id = f"{username}/{profile.preferred_username}-{slug_name}"
313
  print("Creating repo...")
314
  print(user_repo_id)
315
+ create_repo(repo_id=user_repo_id, private=False, exist_ok=True, token=oauth_token.token)
316
  print("Uploading repo...")
317
  upload_folder(
318
  folder_path=folder,
319
  repo_id=user_repo_id,
320
  repo_type="model",
321
+ token=oauth_token.token
322
  )
323
  print("Changing repo visibility...")
324
  #api.update_repo_visibility(repo_id=user_repo_id, private=False)