Save a single result to the results file with incremental updates
(filename: str, result: Dict)
| 200 | |
| 201 | |
| 202 | def save_result(filename: str, result: Dict): |
| 203 | """Save a single result to the results file with incremental updates""" |
| 204 | results = [] |
| 205 | if os.path.exists(filename): |
| 206 | try: |
| 207 | with open(filename, 'r') as f: |
| 208 | results = json.load(f) |
| 209 | except (FileNotFoundError, json.JSONDecodeError): |
| 210 | results = [] |
| 211 | |
| 212 | results.append(result) |
| 213 | |
| 214 | with open(filename, 'w') as f: |
| 215 | json.dump(results, f, indent=2) |
| 216 | |
| 217 | |
| 218 | def load_existing_results(filename: str) -> List[Dict]: |