Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update - improve query lookup for evaluation scenarios #1242

Merged
merged 1 commit into from
Jan 22, 2024
Merged
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
8 changes: 4 additions & 4 deletions agenta-backend/agenta_backend/models/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ async def human_evaluation_db_to_pydantic(


def human_evaluation_scenario_db_to_pydantic(
evaluation_scenario_db: HumanEvaluationScenarioDB,
evaluation_scenario_db: HumanEvaluationScenarioDB, evaluation_id: str
) -> HumanEvaluationScenario:
return HumanEvaluationScenario(
id=str(evaluation_scenario_db.id),
evaluation_id=str(evaluation_scenario_db.evaluation.id),
evaluation_id=evaluation_id,
inputs=evaluation_scenario_db.inputs,
outputs=evaluation_scenario_db.outputs,
vote=evaluation_scenario_db.vote,
Expand Down Expand Up @@ -167,11 +167,11 @@ def evaluation_scenarios_results_to_pydantic(


def evaluation_scenario_db_to_pydantic(
evaluation_scenario_db: EvaluationScenarioDB,
evaluation_scenario_db: EvaluationScenarioDB, evaluation_id: str
) -> EvaluationScenario:
return EvaluationScenario(
id=str(evaluation_scenario_db.id),
evaluation_id=str(evaluation_scenario_db.evaluation.id),
evaluation_id=evaluation_id,
inputs=[
EvaluationScenarioInput(**scenario_input.dict())
for scenario_input in evaluation_scenario_db.inputs
Expand Down
9 changes: 5 additions & 4 deletions agenta-backend/agenta_backend/services/evaluation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ async def fetch_evaluation_scenarios_for_evaluation(
**user_org_data,
)
scenarios = await EvaluationScenarioDB.find(
EvaluationScenarioDB.evaluation.id == ObjectId(evaluation.id), fetch_links=True
EvaluationScenarioDB.evaluation.id == ObjectId(evaluation.id)
).to_list()
eval_scenarios = [
converters.evaluation_scenario_db_to_pydantic(scenario)
converters.evaluation_scenario_db_to_pydantic(scenario, str(evaluation.id))
for scenario in scenarios
]
return eval_scenarios
Expand Down Expand Up @@ -321,10 +321,11 @@ async def fetch_human_evaluation_scenarios_for_evaluation(
)
scenarios = await HumanEvaluationScenarioDB.find(
HumanEvaluationScenarioDB.evaluation.id == ObjectId(evaluation.id),
fetch_links=True,
).to_list()
eval_scenarios = [
converters.human_evaluation_scenario_db_to_pydantic(scenario)
converters.human_evaluation_scenario_db_to_pydantic(
scenario, str(evaluation.id)
)
for scenario in scenarios
]
return eval_scenarios
Expand Down
Loading