(idx: int)
| 176 | ) |
| 177 | |
| 178 | def _run(idx: int) -> EnvRunResult: |
| 179 | try: |
| 180 | result = _run_with_retry(idx) |
| 181 | except Exception as e: |
| 182 | logging.warning('Inference error: %s', str(e)) |
| 183 | result = EnvRunResult( |
| 184 | task_id=idx, |
| 185 | reward=0.0, |
| 186 | info={ |
| 187 | 'error': str(e), |
| 188 | 'traceback': traceback.format_exc(), |
| 189 | 'metrics': dict(reward=0.0), |
| 190 | }, |
| 191 | traj=[], |
| 192 | trial=i, |
| 193 | ) |
| 194 | |
| 195 | if print_results: |
| 196 | print( |
| 197 | '✅' if result.reward == 1 else '❌', |
| 198 | f'task_id={idx}', |
| 199 | ) |
| 200 | print('-----') |
| 201 | with lock: |
| 202 | data = [] |
| 203 | if os.path.exists(ckpt_path): |
| 204 | with open(ckpt_path, 'r') as f: |
| 205 | data = json.load(f) |
| 206 | with open(ckpt_path, 'w') as f: |
| 207 | json.dump(data + [result.model_dump()], f, indent=2) |
| 208 | return result |
| 209 | |
| 210 | with ThreadPoolExecutor(max_workers=config.max_concurrency) as executor: |
| 211 | res = list(executor.map(_run, idxs)) |
nothing calls this directly
no test coverage detected