-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OPIK-573] Implement get_experiment_by_[name, id] and implement Exper…
…iment.get_items() (#868) * Draft implementation of new Experiment API * Add Opik.get_experiment_by_name method * Fix lint errors * Add new properties to experiment * Fix lint errors * Add ExperimentItemContent to __all__ * Update the e2e test for experiment to include items content check * Fix lint errors * Update evaluation unit tests * Remove prompt property * Add docstrings, fix lint errors * Add docstrings to experiment methods * Make both get_experiment_by_* methods raise ExperimentNotFound error if experiment was not found * Update evaluation unit test * Fix lint errors * Rename fields in ExperimentItemContent * Fix lint errors
- Loading branch information
1 parent
a07e974
commit 231ed88
Showing
11 changed files
with
294 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 37 additions & 3 deletions
40
sdks/python/src/opik/api_objects/experiment/experiment_item.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
import dataclasses | ||
|
||
from typing import Optional | ||
from typing import Dict, Any, List, Optional | ||
from opik.types import FeedbackScoreDict | ||
from opik.rest_api.types import experiment_item_compare | ||
|
||
|
||
@dataclasses.dataclass | ||
class ExperimentItem: | ||
class ExperimentItemReferences: | ||
dataset_item_id: str | ||
trace_id: str | ||
id: Optional[str] = None | ||
|
||
|
||
@dataclasses.dataclass | ||
class ExperimentItemContent: | ||
id: str | ||
dataset_item_id: str | ||
trace_id: str | ||
dataset_item_data: Optional[Dict[str, Any]] | ||
evaluation_task_output: Optional[Dict[str, Any]] | ||
feedback_scores: List[FeedbackScoreDict] | ||
|
||
@classmethod | ||
def from_rest_experiment_item_compare( | ||
cls, | ||
value: experiment_item_compare.ExperimentItemCompare, | ||
) -> "ExperimentItemContent": | ||
feedback_scores: List[FeedbackScoreDict] = [ | ||
{ | ||
"category_name": rest_feedback_score.category_name, | ||
"name": rest_feedback_score.name, | ||
"reason": rest_feedback_score.reason, | ||
"value": rest_feedback_score.value, | ||
} | ||
for rest_feedback_score in value.feedback_scores | ||
] | ||
return ExperimentItemContent( | ||
id=value.id, | ||
trace_id=value.trace_id, | ||
dataset_item_id=value.dataset_item_id, | ||
dataset_item_data=value.input, | ||
evaluation_task_output=value.output, | ||
feedback_scores=feedback_scores, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.