sasha HF staff commited on
Commit
9916d63
·
verified ·
1 Parent(s): 52bacd0

Update parse_requests.py

Browse files
Files changed (1) hide show
  1. parse_requests.py +7 -13
parse_requests.py CHANGED
@@ -1,22 +1,16 @@
1
  import os
2
- from huggingface_hub import snapshot_download
3
- import json
4
 
5
  TOKEN = os.environ.get("DEBUG")
6
- requests_dataset = snapshot_download('EnergyStarAI/requests_debug', token=TOKEN, repo_type="dataset", allow_patterns="*.json")
7
 
8
  def normalize_task(task):
9
  # Makes assumption about how the task names are being written, and called.
10
  return '_'.join(task.split()).lower()
11
 
12
 
13
- for dir, path, files in os.walk(requests_dataset):
14
- for fid in files:
15
- file_path = os.path.join(dir, fid)
16
- with open(file_path) as fp:
17
- request = json.load(fp)
18
- status = request['status']
19
- if status == 'PENDING':
20
- model = request['model']
21
- task = normalize_task(request['task'])
22
- print("%s,%s" % (model, task))
 
1
  import os
2
+ from datasets import load_dataset, Dataset
 
3
 
4
  TOKEN = os.environ.get("DEBUG")
5
+ requests_dataset = load_dataset("EnergyStarAI/requests_debug", split="test")
6
 
7
  def normalize_task(task):
8
  # Makes assumption about how the task names are being written, and called.
9
  return '_'.join(task.split()).lower()
10
 
11
 
12
+ requests_dset = requests_dataset.to_pandas()
13
+
14
+ for model, task in requests_dset[['model','task']].loc[requests_dset['status'] == 'PENDING'].to_dict(orient= 'split', index=False)['data']:
15
+ print("%s,%s" % (model, normalize_task(task)))
16
+