@@ -114,17 +114,47 @@ def _download(self) -> List[Dict]:
114
114
raise IndexError (f"Invalid eval_num: { self .eval_num } " )
115
115
build_nums = evals_json ["evals" ][self .eval_num ]["builds" ]
116
116
117
- # collect the 'meta.json' build products
117
+ # fetch build info and download 'meta.json'
118
118
data = []
119
119
for build_num in build_nums :
120
+ # get build info
120
121
resp = requests .get (
121
- f"https://hydra.vtr.tools/build/{ build_num } /download/1/meta.json" ,
122
+ f"https://hydra.vtr.tools/build/{ build_num } " ,
123
+ headers = {"Content-Type" : "application/json" },
124
+ )
125
+ if resp .status_code != 200 :
126
+ raise Exception (f"Unable to get build { build_num } , got status code { resp .status_code } ." )
127
+
128
+ decoded = None
129
+ try :
130
+ decoded = resp .json ()
131
+ except json .decoder .JSONDecodeError as err :
132
+ raise Exception (f"Unable to decode build { build_num } JSON file, { str (err )} " )
133
+
134
+ # check if build was successful
135
+ if decoded .get ("buildstatus" ) != 0 :
136
+ print (f"Warning: Build { build_num } failed with non-zero exit. Skipping..." )
137
+ continue
138
+
139
+ # check if meta.json exists
140
+ meta_json_id = None
141
+ for product_id , product_desc in decoded .get ("buildproducts" , {}).items ():
142
+ if product_desc .get ("name" , "" ) == "meta.json" :
143
+ meta_json_id = product_id
144
+
145
+ if meta_json_id is None :
146
+ print (f"Warning: Build { build_num } does not contain meta.json file. Skipping..." )
147
+ continue
148
+
149
+ # download meta.json
150
+ resp = requests .get (
151
+ f"https://hydra.vtr.tools/build/{ build_num } /download/{ meta_json_id } /meta.json" ,
122
152
headers = {"Content-Type" : "application/json" },
123
153
)
124
154
if resp .status_code != 200 :
125
155
print (
126
156
"Warning:" ,
127
- f"Unable to get build { build_num } . It might have failed ." ,
157
+ f"Unable to get build { build_num } meta.json file ." ,
128
158
)
129
159
continue
130
160
try :
0 commit comments