Jellyfish042 commited on
Commit
aac9ef0
·
1 Parent(s): 16dece6

support submit gated model

Browse files
Files changed (1) hide show
  1. app.py +10 -12
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 scipy.spatial import ConvexHull
 
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(name):
 
227
  try:
228
- huggingface_hub.hf_hub_download(repo_id=name, filename="config.json")
229
  return True
230
- except (EntryNotFoundError, RepositoryNotFoundError):
231
- print(f'Model {name} does not exist Error. 001')
232
- return False
233
- except requests.exceptions.HTTPError:
234
- print('Network error while checking model existence. 002')
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):