Just because it crashes sometimes at the same place, might as well just fix it because we can

#3
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -8,6 +8,7 @@ from tqdm import tqdm
8
  from huggingface_hub import HfApi, CommitOperationAdd, create_commit
9
  import gradio as gr
10
  import datetime
 
11
 
12
  api = HfApi()
13
 
@@ -516,15 +517,18 @@ def search_bar_in_df_fn(search_text):
516
  lists_to_return[index] = apply_headers(lists_to_return[index], headers[index]).head(how_much_list[index])
517
 
518
  return lists_to_return
519
-
520
-
521
  with gr.Blocks() as demo:
522
  gr.Markdown("""<h1 align="center" id="space-title">🤗 Huggingface Leaderboard</h1>""")
523
  gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
524
-
525
- all_models = get_models("models")
526
- all_datasets = get_models("datasets")
527
- all_spaces = get_models("spaces")
 
 
 
 
 
528
 
529
  with gr.Column(min_width=320):
530
  with gr.Box():
 
8
  from huggingface_hub import HfApi, CommitOperationAdd, create_commit
9
  import gradio as gr
10
  import datetime
11
+ from huggingface_hub.utils import HfHubHTTPError
12
 
13
  api = HfApi()
14
 
 
517
  lists_to_return[index] = apply_headers(lists_to_return[index], headers[index]).head(how_much_list[index])
518
 
519
  return lists_to_return
 
 
520
  with gr.Blocks() as demo:
521
  gr.Markdown("""<h1 align="center" id="space-title">🤗 Huggingface Leaderboard</h1>""")
522
  gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
523
+ while True:
524
+ try:
525
+ all_models = get_models("models")
526
+ all_datasets = get_models("datasets")
527
+ all_spaces = get_models("spaces")
528
+ break
529
+ except HfHubHTTPError as error:
530
+ print(f"something went wrong with getting the models, {e}")
531
+ time.sleep(20)
532
 
533
  with gr.Column(min_width=320):
534
  with gr.Box():