Skip to content

Commit

Permalink
Update - improve query lookup for evaluation scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
aybruhm committed Jan 22, 2024
1 parent e276a07 commit a2473ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
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

0 comments on commit a2473ee

Please sign in to comment.