Spaces:
Running
Running
Commit
·
aac9ef0
1
Parent(s):
16dece6
support submit gated model
Browse files
app.py
CHANGED
|
@@ -11,7 +11,8 @@ import plotly.express as px
|
|
| 11 |
import plotly.graph_objects as go
|
| 12 |
from sklearn.linear_model import LinearRegression
|
| 13 |
import numpy as np
|
| 14 |
-
from
|
|
|
|
| 15 |
|
| 16 |
load_dotenv()
|
| 17 |
webhook_url = os.environ.get("WEBHOOK_URL")
|
|
@@ -223,19 +224,16 @@ def update_table(period: str,
|
|
| 223 |
return pd.DataFrame()
|
| 224 |
|
| 225 |
|
| 226 |
-
def check_model_exists(
|
|
|
|
| 227 |
try:
|
| 228 |
-
|
| 229 |
return True
|
| 230 |
-
except
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
return False
|
| 236 |
-
except Exception as e:
|
| 237 |
-
print(e, '003')
|
| 238 |
-
return False
|
| 239 |
|
| 240 |
|
| 241 |
def submit_model(name):
|
|
|
|
| 11 |
import plotly.graph_objects as go
|
| 12 |
from sklearn.linear_model import LinearRegression
|
| 13 |
import numpy as np
|
| 14 |
+
from huggingface_hub import HfApi, HfFolder
|
| 15 |
+
from huggingface_hub.hf_api import HTTPError
|
| 16 |
|
| 17 |
load_dotenv()
|
| 18 |
webhook_url = os.environ.get("WEBHOOK_URL")
|
|
|
|
| 224 |
return pd.DataFrame()
|
| 225 |
|
| 226 |
|
| 227 |
+
def check_model_exists(model_id):
|
| 228 |
+
api = HfApi()
|
| 229 |
try:
|
| 230 |
+
model_info = api.model_info(model_id)
|
| 231 |
return True
|
| 232 |
+
except HTTPError as e:
|
| 233 |
+
if e.response.status_code == 404:
|
| 234 |
+
return False
|
| 235 |
+
else:
|
| 236 |
+
raise
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
|
| 238 |
|
| 239 |
def submit_model(name):
|