Skip to content

Commit

Permalink
fix: unflatten attributes when loading spans from trace_dataset (#3170
Browse files Browse the repository at this point in the history
)
  • Loading branch information
RogerHYang committed May 11, 2024
1 parent 7e17cb2 commit a165023
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/phoenix/trace/trace_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from phoenix.config import DATASET_DIR, GENERATED_DATASET_NAME_PREFIX, TRACE_DATASET_DIR
from phoenix.datetime_utils import normalize_timestamps
from phoenix.trace.attributes import unflatten
from phoenix.trace.errors import InvalidParquetMetadataError
from phoenix.trace.schemas import ATTRIBUTE_PREFIX, CONTEXT_PREFIX, Span
from phoenix.trace.span_evaluations import Evaluations, SpanEvaluations
Expand Down Expand Up @@ -161,13 +162,13 @@ def to_spans(self) -> Iterator[Span]:
for _, row in self.dataframe.iterrows():
is_attribute = row.index.str.startswith(ATTRIBUTE_PREFIX)
attribute_keys = row.index[is_attribute]
attributes = (
attributes = unflatten(
row.loc[is_attribute]
.rename(
{key: key[len(ATTRIBUTE_PREFIX) :] for key in attribute_keys},
)
.dropna()
.to_dict()
.items()
)
is_context = row.index.str.startswith(CONTEXT_PREFIX)
context_keys = row.index[is_context]
Expand Down

0 comments on commit a165023

Please sign in to comment.