meg-huggingface commited on
Commit
27979f6
·
1 Parent(s): 1bc807f

Attempting reading the requests using snapshot_download instead of the datasets package.

Browse files
Files changed (1) hide show
  1. parse_requests.py +17 -9
parse_requests.py CHANGED
@@ -1,15 +1,23 @@
1
- from datasets import load_dataset
 
 
2
 
3
-
4
- requests_dataset = load_dataset('EnergyStarAI/requests_debug')['test']
5
 
6
  def normalize_task(task):
7
  # Makes assumption about how the task names are being written, and called.
8
  return '_'.join(task.split()).lower()
9
 
10
- for request in requests_dataset:
11
- status = request['status']
12
- if status == 'PENDING':
13
- model = request['model']
14
- task = normalize_task(request['task'])
15
- print("%s,%s" % (model, task))
 
 
 
 
 
 
 
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")
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
+ if fid.endswith('.json'):
16
+ file_path = os.path.join(dir, fid)
17
+ with open(file_path) as fp:
18
+ request = json.load(fp)
19
+ status = request['status']
20
+ if status == 'PENDING':
21
+ model = request['model']
22
+ task = normalize_task(request['task'])
23
+ print("%s,%s" % (model, task))