Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pydantic_evals/pydantic_evals/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ async def _handle_case(case: Case[InputsT, OutputT, MetadataT], report_case_name
trace_id=trace_id,
)
if (averages := report.averages()) is not None and averages.assertions is not None:
experiment_metadata = {'n_cases': len(self.cases), 'averages': averages}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the test below, it looks like we already had n_cases in here, do we need to repeat it? Or could we drop it there and have it just under the metadata?

eval_span.set_attribute('experiment.metadata', experiment_metadata)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a logfire. prefix here since it's not general OTel but specific to our platform?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue it's specific to pydantic evals, rather than logfire itself?

We use the experiment.metadata field to ingest information about the test run. Are you saying we should change this to logfire.experiment.metadata ? or are you saying underneath experiment.metadata we should have a logfire field.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cetra3 Yeah I was suggesting (based on @alexmojaki suggestion in Slack) to change it to logfire.experiment.metadata. But I see your (implied) point that even though right now only Logfire will use these attributes, they could be useful to users sending pydantic_evals data to different platform as well.

@alexmojaki What do you think about a pydantic_evals prefix?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything here is specific to pydantic evals. This is particularly specific not just to logfire but to fusionfire popped attributes. n_cases is being repeated here so that it can be displayed cheaply in the frontend. We may add or remove things here freely depending on what the frontend needs, it's not intended to be queried. I think logfire. makes sense for that.

eval_span.set_attribute('assertion_pass_rate', averages.assertions)
return report

Expand Down
28 changes: 27 additions & 1 deletion tests/evals/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,10 +1496,36 @@ async def mock_async_task(inputs: TaskInput) -> TaskOutput:
'assertion_pass_rate': 1.0,
'logfire.msg_template': 'evaluate {name}',
'logfire.msg': 'evaluate mock_async_task',
'experiment.metadata': {
'n_cases': 2,
'averages': {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to be using this on the frontend, I don't know if it's wise to pass along the entire ReportCaseAggregate object or just the subset we need

'name': 'Averages',
'scores': {'confidence': 1.0},
'labels': {},
'metrics': {},
'assertions': 1.0,
'task_duration': 1.0,
'total_duration': 9.0,
},
},
'logfire.span_type': 'span',
'logfire.json_schema': {
'type': 'object',
'properties': {'name': {}, 'n_cases': {}, 'assertion_pass_rate': {}},
'properties': {
'name': {},
'n_cases': {},
'experiment.metadata': {
'type': 'object',
'properties': {
'averages': {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect n_cases to also be listed here

'type': 'object',
'title': 'ReportCaseAggregate',
'x-python-datatype': 'PydanticModel',
}
},
},
'assertion_pass_rate': {},
},
},
},
),
Expand Down