Skip to content

Commit 9d2a0cb

Browse files
committed
iterate over rows to get columns
1 parent 755d632 commit 9d2a0cb

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
@@ -883,7 +884,6 @@ async def finish(self) -> None:
883884

884885
async def log_samples(self, samples: Dict[str, List[dict]], step: int) -> None:
885886
"""Pretty-print sample-level logs to console."""
886-
import json
887887

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

10521052
# If table doesn't exist yet, create it in INCREMENTAL mode
10531053
if table_name not in self._tables:
1054-
columns = list(table_rows[0].keys())
1054+
# Collect all unique columns from all rows
1055+
columns = set()
1056+
for row in table_rows:
1057+
columns.update(row.keys())
1058+
columns = sorted(columns) # Sort for consistent column ordering
10551059
table = wandb.Table(columns=columns, log_mode="INCREMENTAL")
10561060
self._tables[table_name] = table
10571061
logger.debug(
1058-
f"WandbBackend: Created new incremental table: {table_name}"
1062+
f"WandbBackend: Created new incremental table: {table_name} with columns: {columns}"
10591063
)
10601064
else:
10611065
table = self._tables[table_name]

0 commit comments

Comments
 (0)