basic error handling
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
from huggingface_hub import HfApi
|
|
|
|
| 5 |
import pandas as pd
|
| 6 |
import plotly.express as px
|
| 7 |
|
|
@@ -52,8 +53,19 @@ def repo_size(r_type, r_id):
|
|
| 52 |
|
| 53 |
|
| 54 |
def get_repo_info(r_type, r_id):
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
rf_sizes_df = (
|
| 58 |
pd.DataFrame(repo_files_info)
|
| 59 |
.T.reset_index(names="ext")
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
from huggingface_hub import HfApi
|
| 5 |
+
from huggingface_hub.errors import RepositoryNotFoundError
|
| 6 |
import pandas as pd
|
| 7 |
import plotly.express as px
|
| 8 |
|
|
|
|
| 53 |
|
| 54 |
|
| 55 |
def get_repo_info(r_type, r_id):
|
| 56 |
+
try:
|
| 57 |
+
repo_sizes = repo_size(r_type, r_id)
|
| 58 |
+
repo_files_info = repo_files(r_type, r_id)
|
| 59 |
+
except RepositoryNotFoundError:
|
| 60 |
+
gr.Warning(
|
| 61 |
+
"Repository not found. Make sure you've entered a valid repo ID and type that corresponds to the repository."
|
| 62 |
+
)
|
| 63 |
+
return (
|
| 64 |
+
gr.Row(visible=False),
|
| 65 |
+
gr.Dataframe(visible=False),
|
| 66 |
+
gr.Plot(visible=False),
|
| 67 |
+
gr.Dataframe(visible=False),
|
| 68 |
+
)
|
| 69 |
rf_sizes_df = (
|
| 70 |
pd.DataFrame(repo_files_info)
|
| 71 |
.T.reset_index(names="ext")
|