10
10
import sys
11
11
from collections .abc import Iterator , Sequence
12
12
from glob import glob
13
- from typing import Optional , Union
13
+ from typing import Any , Optional , Union
14
14
15
15
try :
16
16
import git
140
140
parser .add_argument ("-c" , "--compare" , help = help_c )
141
141
help_t = (
142
142
"The tool whose data is being compared. "
143
- "Either 'llama-bench' (default) or 'test-backend-ops'. "
143
+ "Either 'llama-bench' or 'test-backend-ops'. "
144
144
"This determines the database schema and comparison logic used."
145
145
)
146
- parser .add_argument ("-t" , "--tool" , help = help_t , default = "llama-bench" , choices = ["llama-bench" , "test-backend-ops" ])
146
+ parser .add_argument ("-t" , "--tool" , help = help_t , default = None , choices = [None , "llama-bench" , "test-backend-ops" ])
147
147
help_i = (
148
148
"JSON/JSONL/SQLite/CSV files for comparing commits. "
149
149
"Specify multiple times to use multiple input files (JSON/CSV only). "
@@ -394,7 +394,7 @@ def _get_rows_test_backend_ops(self, properties: list[str], hexsha8_baseline: st
394
394
395
395
396
396
class LlamaBenchDataSQLite3File (LlamaBenchDataSQLite3 ):
397
- def __init__ (self , data_file : str , tool : str = "llama-bench" ):
397
+ def __init__ (self , data_file : str , tool : Any ):
398
398
super ().__init__ (tool )
399
399
400
400
self .connection .close ()
@@ -405,18 +405,30 @@ def __init__(self, data_file: str, tool: str = "llama-bench"):
405
405
tables = self .cursor .execute ("SELECT name FROM sqlite_master WHERE type='table';" ).fetchall ()
406
406
table_names = [table [0 ] for table in tables ]
407
407
408
- if "test_backend_ops" in table_names and tool == "test-backend-ops" :
409
- self .table_name = "test_backend_ops"
410
- elif "test" in table_names and tool == "llama-bench" :
411
- self .table_name = "test"
412
- elif "test" in table_names :
413
- # Fallback to test table for backward compatibility
414
- self .table_name = "test"
415
- if tool == "test-backend-ops" :
416
- logger .warning ("test-backend-ops tool specified but only 'test' table found. Assuming llama-bench data." )
408
+ # Tool selection logic
409
+ if tool is None :
410
+ if "test" in table_names :
411
+ self .table_name = "test"
417
412
self .tool = "llama-bench"
413
+ elif "test_backend_ops" in table_names :
414
+ self .table_name = "test_backend_ops"
415
+ self .tool = "test-backend-ops"
416
+ else :
417
+ raise RuntimeError (f"No suitable table found in database. Available tables: { table_names } " )
418
+ elif tool == "llama-bench" :
419
+ if "test" in table_names :
420
+ self .table_name = "test"
421
+ self .tool = "llama-bench"
422
+ else :
423
+ raise RuntimeError (f"Table 'test' not found for tool 'llama-bench'. Available tables: { table_names } " )
424
+ elif tool == "test-backend-ops" :
425
+ if "test_backend_ops" in table_names :
426
+ self .table_name = "test_backend_ops"
427
+ self .tool = "test-backend-ops"
428
+ else :
429
+ raise RuntimeError (f"Table 'test_backend_ops' not found for tool 'test-backend-ops'. Available tables: { table_names } " )
418
430
else :
419
- raise RuntimeError (f"No suitable table found for tool ' { tool } ' in database. Available tables : { table_names } " )
431
+ raise RuntimeError (f"Unknown tool: { tool } " )
420
432
421
433
self ._builds_init ()
422
434
0 commit comments