|
1 | 1 | import json |
2 | 2 | from datetime import datetime |
| 3 | +from pathlib import Path |
3 | 4 | from typing import List |
4 | 5 |
|
5 | 6 | from benchmark import ROOT_DIR |
@@ -54,7 +55,11 @@ def save_upload_results( |
54 | 55 | out.write(json.dumps(upload_stats, indent=2)) |
55 | 56 |
|
56 | 57 | def run_experiment( |
57 | | - self, dataset: Dataset, skip_upload: bool = False, skip_search: bool = False |
| 58 | + self, |
| 59 | + dataset: Dataset, |
| 60 | + skip_upload: bool = False, |
| 61 | + skip_search: bool = False, |
| 62 | + skip_if_exists: bool = False, |
58 | 63 | ): |
59 | 64 | execution_params = self.configurator.execution_params( |
60 | 65 | distance=dataset.config.distance, vector_size=dataset.config.vector_size |
@@ -82,6 +87,18 @@ def run_experiment( |
82 | 87 | if not skip_search: |
83 | 88 | print("Experiment stage: Search") |
84 | 89 | for search_id, searcher in enumerate(self.searchers): |
| 90 | + |
| 91 | + if skip_if_exists: |
| 92 | + existing_results = RESULTS_DIR.glob( |
| 93 | + f"{self.name}-{dataset.config.name}-search-{search_id}-*.json" |
| 94 | + ) |
| 95 | + if len(existing_results) == 1: |
| 96 | + print( |
| 97 | + f"Skipping search {search_id} as it already exists in", |
| 98 | + existing_results[0], |
| 99 | + ) |
| 100 | + continue |
| 101 | + |
85 | 102 | search_params = {**searcher.search_params} |
86 | 103 | search_stats = searcher.search_all( |
87 | 104 | dataset.config.distance, reader.read_queries() |
|
0 commit comments