Skip to content

Commit

Permalink
integrated versioning into evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmabrouk committed Jan 23, 2024
1 parent e4d6ccf commit b9d261c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions agenta-backend/agenta_backend/models/api/evaluation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class Evaluation(BaseModel):
user_username: str
variant_ids: List[str]
variant_names: List[str]
variant_revision_ids: List[str]
revisions: List[str]
testset_id: str
testset_name: str
status: str
Expand Down
7 changes: 6 additions & 1 deletion agenta-backend/agenta_backend/models/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,19 @@ async def evaluation_db_to_pydantic(
str(evaluation_db.variant)
)
variant_name = variant.variant_name if variant else str(evaluation_db.variant)

variant_revision = await db_manager.get_app_variant_revision_by_id(
str(evaluation_db.variant_revision)
)
revision = str(variant_revision.revision)
return Evaluation(
id=str(evaluation_db.id),
app_id=str(evaluation_db.app.id),
user_id=str(evaluation_db.user.id),
user_username=evaluation_db.user.username or "",
status=evaluation_db.status,
variant_ids=[str(evaluation_db.variant)],
variant_revision_ids=[str(evaluation_db.variant_revision)],
revisions=[revision],
variant_names=[variant_name],
testset_id=str(evaluation_db.testset.id),
testset_name=evaluation_db.testset.name,
Expand Down
1 change: 1 addition & 0 deletions agenta-backend/agenta_backend/models/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class EvaluationDB(Document):
status: str = Field(default="EVALUATION_INITIALIZED")
testset: Link[TestSetDB]
variant: PydanticObjectId
variant_revision: PydanticObjectId
evaluators_configs: List[PydanticObjectId]
aggregated_results: List[AggregatedResult]
created_at: datetime = Field(default=datetime.utcnow())
Expand Down
4 changes: 3 additions & 1 deletion agenta-backend/agenta_backend/services/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,8 @@ async def create_new_evaluation(
user: UserDB,
testset: TestSetDB,
status: str,
variant: AppVariantDB,
variant: str,
variant_revision: str,
evaluators_configs: List[str],
) -> EvaluationDB:
"""Create a new evaluation scenario.
Expand All @@ -1667,6 +1668,7 @@ async def create_new_evaluation(
testset=testset,
status=status,
variant=variant,
variant_revision=variant_revision,
evaluators_configs=evaluators_configs,
aggregated_results=[],
created_at=datetime.now().isoformat(),
Expand Down
5 changes: 5 additions & 0 deletions agenta-backend/agenta_backend/services/evaluation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,10 @@ async def create_new_evaluation(
app = await db_manager.fetch_app_by_id(app_id=app_id)

testset = await db_manager.fetch_testset_by_id(testset_id)
variant_db = await db_manager.get_app_variant_instance_by_id(variant_id)
variant_revision = await db_manager.fetch_app_variant_revision_by_variant(
variant_id, variant_db.revision
)

evaluation_db = await db_manager.create_new_evaluation(
app=app,
Expand All @@ -696,6 +700,7 @@ async def create_new_evaluation(
testset=testset,
status=EvaluationStatusEnum.EVALUATION_STARTED,
variant=variant_id,
variant_revision=str(variant_revision.id),
evaluators_configs=evaluator_config_ids,
)
return await converters.evaluation_db_to_pydantic(evaluation_db)
Expand Down

0 comments on commit b9d261c

Please sign in to comment.