Skip to content

Commit

Permalink
Update unit tests and backend emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkuzmik committed Jan 21, 2025
1 parent a70df2b commit 53b8e18
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def _dispatch_message(self, message: messages.BaseMessage) -> None:
model=message.model,
provider=message.provider,
error_info=message.error_info,
total_cost=message.total_cost,
)

self._span_to_parent_span[span.id] = message.parent_span_id
Expand Down Expand Up @@ -156,6 +157,7 @@ def _dispatch_message(self, message: messages.BaseMessage) -> None:
"error_info": message.error_info,
"tags": message.tags,
"input": message.input,
"total_cost": message.total_cost,
}
cleaned_update_payload = dict_utils.remove_none_from_dict(update_payload)
span.__dict__.update(cleaned_update_payload)
Expand Down
1 change: 1 addition & 0 deletions sdks/python/tests/testlib/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SpanModel:
model: Optional[str] = None
provider: Optional[str] = None
error_info: Optional[ErrorInfoDict] = None
total_cost: Optional[float] = None


@dataclasses.dataclass
Expand Down
5 changes: 4 additions & 1 deletion sdks/python/tests/unit/decorator/test_tracker_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,9 @@ def test_track__span_and_trace_updated_via_opik_context(fake_backend):
@tracker.track
def f(x):
opik_context.update_current_span(
name="span-name", metadata={"span-metadata-key": "span-metadata-value"}
name="span-name",
metadata={"span-metadata-key": "span-metadata-value"},
total_cost=0.42,
)
opik_context.update_current_trace(
name="trace-name",
Expand Down Expand Up @@ -1087,6 +1089,7 @@ def f(x):
output={"output": "f-output"},
start_time=ANY_BUT_NONE,
end_time=ANY_BUT_NONE,
total_cost=0.42,
spans=[],
)
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def test_batch_manager__start_and_stop_were_called__accumulated_data_is_flushed(
model=NOT_USED,
provider=NOT_USED,
error_info=NOT_USED,
total_cost=NOT_USED,
)

example_span_batcher = batchers.CreateSpanMessageBatcher(
Expand Down

0 comments on commit 53b8e18

Please sign in to comment.