Skip to content

Commit 5c67488

Browse files
committed
iterate over rows to get columns
1 parent dfcbaba commit 5c67488

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/forge/observability/metrics.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import asyncio
88
import heapq
99
import itertools
10+
import json
1011
import logging
1112
import os
1213
from abc import ABC, abstractmethod
@@ -868,7 +869,6 @@ async def finish(self) -> None:
868869

869870
async def log_samples(self, samples: Dict[str, List[dict]], step: int) -> None:
870871
"""Pretty-print sample-level logs to console."""
871-
import json
872872

873873
logger.info(f"========== SAMPLE LOGS STEP {step} ==========")
874874
for table_name, table_rows in samples.items():
@@ -1027,11 +1027,15 @@ async def log_samples(self, samples: Dict[str, List[dict]], step: int) -> None:
10271027

10281028
# If table doesn't exist yet, create it in INCREMENTAL mode
10291029
if table_name not in self._tables:
1030-
columns = list(table_rows[0].keys())
1030+
# Collect all unique columns from all rows
1031+
columns = set()
1032+
for row in table_rows:
1033+
columns.update(row.keys())
1034+
columns = sorted(columns) # Sort for consistent column ordering
10311035
table = wandb.Table(columns=columns, log_mode="INCREMENTAL")
10321036
self._tables[table_name] = table
10331037
logger.debug(
1034-
f"WandbBackend: Created new incremental table: {table_name}"
1038+
f"WandbBackend: Created new incremental table: {table_name} with columns: {columns}"
10351039
)
10361040
else:
10371041
table = self._tables[table_name]

0 commit comments

Comments
 (0)