@@ -145,16 +145,15 @@ def load_configs(point_type: str, base_dir: str = "ann_benchmarks/algorithms") -
145
145
print (f"Error loading YAML from { config_file } : { e } " )
146
146
return configs
147
147
148
- def _get_definitions (base_dir : str = "ann_benchmarks/algorithms" ) -> Dict [ str , Dict [str , Any ]]:
149
- """Load algorithm configurations for a given point_type ."""
148
+ def _get_definitions (base_dir : str = "ann_benchmarks/algorithms" ) -> List [ Dict [str , Any ]]:
149
+ """Load algorithm configurations."""
150
150
config_files = get_config_files (base_dir = base_dir )
151
- configs = {}
151
+ configs = []
152
152
for config_file in config_files :
153
153
with open (config_file , 'r' ) as stream :
154
154
try :
155
155
config_data = yaml .safe_load (stream )
156
- algorithm_name = os .path .basename (os .path .dirname (config_file ))
157
- configs [algorithm_name ] = config_data
156
+ configs .append (config_data )
158
157
except yaml .YAMLError as e :
159
158
print (f"Error loading YAML from { config_file } : { e } " )
160
159
return configs
@@ -211,16 +210,27 @@ def list_algorithms(base_dir: str = "ann_benchmarks/algorithms") -> None:
211
210
base_dir (str, optional): The base directory where the algorithms are stored.
212
211
Defaults to "ann_benchmarks/algorithms".
213
212
"""
214
- definitions = _get_definitions (base_dir )
215
-
216
- print ("The following algorithms are supported..." , definitions )
217
- for algorithm in definitions :
213
+ all_configs = _get_definitions (base_dir )
214
+ data = {}
215
+ for algo_configs in all_configs :
216
+ for point_type , config_for_point_type in algo_configs .items ():
217
+ for metric , ccc in config_for_point_type .items ():
218
+ algo_name = ccc [0 ]["name" ]
219
+ if algo_name not in data :
220
+ data [algo_name ] = {}
221
+ if point_type not in data [algo_name ]:
222
+ data [algo_name ][point_type ] = []
223
+ data [algo_name ][point_type ].append (metric )
224
+
225
+ print ("The following algorithms are supported:" , ", " .join (data ))
226
+ print ("Details of supported metrics and data types: " )
227
+ for algorithm in data :
218
228
print ('\t ... for the algorithm "%s"...' % algorithm )
219
229
220
- for point_type in definitions [algorithm ]:
230
+ for point_type in data [algorithm ]:
221
231
print ('\t \t ... and the point type "%s", metrics: ' % point_type )
222
232
223
- for metric in definitions [algorithm ][point_type ]:
233
+ for metric in data [algorithm ][point_type ]:
224
234
print ("\t \t \t %s" % metric )
225
235
226
236
0 commit comments