Skip to content

Commit f6c4755

Browse files
committed
optimize queries
1 parent 73f17d0 commit f6c4755

2 files changed

Lines changed: 191 additions & 156 deletions

File tree

trackio/cli.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,21 +1531,28 @@ def main():
15311531
configs = SQLiteStorage.get_all_run_configs(args.project)
15321532
run_names = [r["name"] for r in all_records]
15331533
has_dupes = len(run_names) != len(set(run_names))
1534+
target_ids = [r["id"] for r in all_records if r.get("id")]
15341535

1535-
comparison = []
1536-
for rec in all_records:
1537-
run = rec["name"]
1538-
run_metrics = {}
1536+
metric_values_by_id: dict[str, dict[str, float]] = {}
1537+
if target_ids:
15391538
for metric in metric_names:
1540-
values = SQLiteStorage.get_final_metric_for_runs(
1539+
rows = SQLiteStorage.get_final_metric_for_runs(
15411540
args.project,
15421541
metric,
15431542
mode=args.mode,
1544-
run_names=[run],
1543+
run_ids=target_ids,
15451544
status_filter=None,
15461545
)
1547-
if values:
1548-
run_metrics[metric] = values[0]["value"]
1546+
for row in rows:
1547+
rid = row.get("run_id")
1548+
if rid:
1549+
metric_values_by_id.setdefault(rid, {})[metric] = row["value"]
1550+
1551+
comparison = []
1552+
for rec in all_records:
1553+
run = rec["name"]
1554+
rid = rec.get("id")
1555+
run_metrics = metric_values_by_id.get(rid, {}) if rid else {}
15491556
comparison.append(
15501557
{
15511558
"id": rec["id"],

0 commit comments

Comments
 (0)