Spaces:
Runtime error
Runtime error
Benjamin Bossan
commited on
Commit
•
2923fea
1
Parent(s):
2481b28
Error handling for incorrect repo id
Browse files
start.py
CHANGED
@@ -22,6 +22,7 @@ import pandas as pd
|
|
22 |
import sklearn
|
23 |
import streamlit as st
|
24 |
from huggingface_hub import hf_hub_download
|
|
|
25 |
from sklearn.base import BaseEstimator
|
26 |
from sklearn.dummy import DummyClassifier
|
27 |
|
@@ -126,8 +127,15 @@ def create_hf_model_card() -> None:
|
|
126 |
if not repo_id:
|
127 |
return
|
128 |
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
model_card = card.parse_modelcard(path)
|
132 |
st.session_state.model_card = model_card
|
133 |
st.session_state.model_card_type = "loaded"
|
|
|
22 |
import sklearn
|
23 |
import streamlit as st
|
24 |
from huggingface_hub import hf_hub_download
|
25 |
+
from huggingface_hub.utils import HFValidationError, RepositoryNotFoundError
|
26 |
from sklearn.base import BaseEstimator
|
27 |
from sklearn.dummy import DummyClassifier
|
28 |
|
|
|
127 |
if not repo_id:
|
128 |
return
|
129 |
|
130 |
+
try:
|
131 |
+
path = hf_hub_download(repo_id, "README.md")
|
132 |
+
except (HFValidationError, RepositoryNotFoundError):
|
133 |
+
st.error(
|
134 |
+
f"Repository '{repo_id}' could not be found on HF Hub, "
|
135 |
+
"please check that the repo ID is correct."
|
136 |
+
)
|
137 |
+
return
|
138 |
+
|
139 |
model_card = card.parse_modelcard(path)
|
140 |
st.session_state.model_card = model_card
|
141 |
st.session_state.model_card_type = "loaded"
|