gblazex commited on
Commit
9e5373d
·
1 Parent(s): 2477ab0

download dataset with Repository() api

Browse files
Files changed (1) hide show
  1. app.py +24 -6
app.py CHANGED
@@ -30,21 +30,39 @@ from src.populate import get_evaluation_queue_df, get_leaderboard_df
30
  from src.submission.submit import add_new_eval
31
 
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  def restart_space():
34
  API.restart_space(repo_id=REPO_ID, token=TOKEN)
35
 
 
36
  try:
37
  print(EVAL_REQUESTS_PATH)
38
- snapshot_download(
39
- repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30
40
- )
 
 
41
  except Exception:
42
  restart_space()
43
  try:
44
  print(EVAL_RESULTS_PATH)
45
- snapshot_download(
46
- repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30
47
- )
 
48
  except Exception:
49
  restart_space()
50
 
 
30
  from src.submission.submit import add_new_eval
31
 
32
 
33
+ from huggingface_hub import hf_hub_download, Repository
34
+
35
+ def download_dataset(repo_id, local_dir):
36
+ # Clone the repository
37
+ repo_id_full = f"https://huggingface.co/datasets/{repo_id}"
38
+ repo = Repository(local_dir=local_dir, clone_from=repo_id_full)
39
+ # Alternatively, you can download specific files using hf_hub_download
40
+ # file_path = hf_hub_download(repo_id, filename="your_file_name")
41
+
42
+ # Usage
43
+ #download_dataset("https://huggingface.co/datasets/open-llm-leaderboard/requests", "new/requests")
44
+ #download_dataset("datasets/open-llm-leaderboard/results", "new/results")
45
+
46
+
47
  def restart_space():
48
  API.restart_space(repo_id=REPO_ID, token=TOKEN)
49
 
50
+
51
  try:
52
  print(EVAL_REQUESTS_PATH)
53
+ download_dataset(repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH)
54
+ #snapshot_download(
55
+ # repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30
56
+ #)
57
+
58
  except Exception:
59
  restart_space()
60
  try:
61
  print(EVAL_RESULTS_PATH)
62
+ download_dataset(repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH)
63
+ #snapshot_download(
64
+ # repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30
65
+ #)
66
  except Exception:
67
  restart_space()
68