4
4
import pandas as pd
5
5
from huggingface_hub import create_repo , snapshot_download , upload_file , repo_exists
6
6
from optimum_benchmark import Benchmark
7
- import requests
8
7
import json
9
8
10
9
from llm_perf .common .hardware_config import load_hardware_configs
19
18
PERF_DF = "perf-df-{backend}-{hardware}-{subset}-{machine}.csv"
20
19
LLM_DF = "llm-df.csv"
21
20
21
+
22
22
def patch_json (file ):
23
23
"""
24
24
Patch a JSON file by adding a 'stdev_' key with the same value as 'stdev' for all occurrences,
@@ -37,7 +37,7 @@ def patch_json(file):
37
37
"""
38
38
with open (file , "r" ) as f :
39
39
data = json .load (f )
40
-
40
+
41
41
def add_stdev_ (obj ):
42
42
if isinstance (obj , dict ):
43
43
new_items = []
@@ -53,10 +53,11 @@ def add_stdev_(obj):
53
53
add_stdev_ (item )
54
54
55
55
add_stdev_ (data )
56
-
56
+
57
57
with open (file , "w" ) as f :
58
58
json .dump (data , f , indent = 4 )
59
59
60
+
60
61
def gather_benchmarks (subset : str , machine : str , backend : str , hardware : str ):
61
62
"""
62
63
Gather the benchmarks for a given machine
@@ -99,7 +100,6 @@ def gather_benchmarks(subset: str, machine: str, backend: str, hardware: str):
99
100
# return response.status_code == 200
100
101
101
102
102
-
103
103
def update_perf_dfs ():
104
104
"""
105
105
Update the performance dataframes for all machines
@@ -116,19 +116,18 @@ def update_perf_dfs():
116
116
backend ,
117
117
hardware_config .hardware ,
118
118
)
119
- except Exception as e :
119
+ except Exception :
120
120
print ("Dataset not found for:" )
121
121
print (f" • Backend: { backend } " )
122
122
print (f" • Subset: { subset } " )
123
123
print (f" • Machine: { hardware_config .machine } " )
124
124
print (f" • Hardware Type: { hardware_config .hardware } " )
125
125
url = f"{ PERF_REPO_ID .format (subset = subset , machine = hardware_config .machine , backend = backend , hardware = hardware_config .hardware )} "
126
-
126
+
127
127
does_exist = repo_exists (url , repo_type = "dataset" )
128
128
129
129
if does_exist :
130
130
print (f"Dataset exists: { url } but could not be processed" )
131
-
132
131
133
132
134
133
scrapping_script = """
0 commit comments