Quentin Gallouédec commited on
Commit
5174522
1 Parent(s): 3922a8b

proper use of api

Browse files
Files changed (3) hide show
  1. app.py +2 -2
  2. src/backend.py +2 -2
  3. src/evaluation.py +2 -2
app.py CHANGED
@@ -6,7 +6,7 @@ import gradio as gr
6
  import numpy as np
7
  import pandas as pd
8
  from apscheduler.schedulers.background import BackgroundScheduler
9
- from huggingface_hub import HfApi, hf_hub_download
10
 
11
  from src.backend import backend_routine
12
 
@@ -127,7 +127,7 @@ def get_leaderboard_df():
127
 
128
  data = []
129
  for filename in filenames:
130
- path = hf_hub_download(repo_id=RESULTS_REPO, filename=filename, repo_type="dataset")
131
  with open(path) as fp:
132
  report = json.load(fp)
133
  user_id, model_id = report["config"]["model_id"].split("/")
 
6
  import numpy as np
7
  import pandas as pd
8
  from apscheduler.schedulers.background import BackgroundScheduler
9
+ from huggingface_hub import HfApi
10
 
11
  from src.backend import backend_routine
12
 
 
127
 
128
  data = []
129
  for filename in filenames:
130
+ path = API.hf_hub_download(repo_id=RESULTS_REPO, filename=filename, repo_type="dataset")
131
  with open(path) as fp:
132
  report = json.load(fp)
133
  user_id, model_id = report["config"]["model_id"].split("/")
src/backend.py CHANGED
@@ -3,7 +3,7 @@ import os
3
  import re
4
  import tempfile
5
 
6
- from huggingface_hub import CommitOperationAdd, HfApi, hf_hub_download
7
 
8
  from src.evaluation import evaluate
9
  from src.logging import setup_logger
@@ -33,7 +33,7 @@ def _backend_routine():
33
 
34
  evaluated_models = set()
35
  for filename in filenames:
36
- path = hf_hub_download(repo_id=RESULTS_REPO, filename=filename, repo_type="dataset")
37
  with open(path) as fp:
38
  report = json.load(fp)
39
  evaluated_models.add((report["config"]["model_id"], report["config"]["model_sha"]))
 
3
  import re
4
  import tempfile
5
 
6
+ from huggingface_hub import CommitOperationAdd, HfApi
7
 
8
  from src.evaluation import evaluate
9
  from src.logging import setup_logger
 
33
 
34
  evaluated_models = set()
35
  for filename in filenames:
36
+ path = API.hf_hub_download(repo_id=RESULTS_REPO, filename=filename, repo_type="dataset")
37
  with open(path) as fp:
38
  report = json.load(fp)
39
  evaluated_models.add((report["config"]["model_id"], report["config"]["model_sha"]))
src/evaluation.py CHANGED
@@ -6,7 +6,7 @@ import gymnasium as gym
6
  import numpy as np
7
  import torch
8
  from gymnasium import wrappers
9
- from huggingface_hub import HfApi, hf_hub_download
10
  from huggingface_hub.utils._errors import EntryNotFoundError
11
 
12
  from src.logging import setup_logger
@@ -236,7 +236,7 @@ def evaluate(model_id, revision):
236
 
237
  # Check if the agent exists
238
  try:
239
- agent_path = hf_hub_download(repo_id=model_id, filename="agent.pt")
240
  except EntryNotFoundError:
241
  logger.error("Agent not found")
242
  return None
 
6
  import numpy as np
7
  import torch
8
  from gymnasium import wrappers
9
+ from huggingface_hub import HfApi
10
  from huggingface_hub.utils._errors import EntryNotFoundError
11
 
12
  from src.logging import setup_logger
 
236
 
237
  # Check if the agent exists
238
  try:
239
+ agent_path = API.hf_hub_download(repo_id=model_id, filename="agent.pt")
240
  except EntryNotFoundError:
241
  logger.error("Agent not found")
242
  return None