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

Refactor/add function to fetch corresponding object UUID #1851

Merged
Merged
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
21 changes: 21 additions & 0 deletions agenta-backend/agenta_backend/services/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
)
from agenta_backend.models.db_models import (
TemplateDB,
IDsMappingDB,
AppVariantRevisionsDB,
HumanEvaluationVariantDB,
EvaluationScenarioResultDB,
Expand Down Expand Up @@ -3094,3 +3095,23 @@ async def check_if_evaluation_contains_failed_evaluation_scenarios(
if not count:
return False
return count > 0


async def fetch_corresponding_object_uuid(table_name: str, object_id: str) -> str:
"""
Fetches a corresponding object uuid.

Args:
table_name (str): The table name
object_id (str): The object identifier

Returns:
The corresponding object uuid as string.
"""

async with db_engine.get_session() as session:
result = await session.execute(
select(IDsMappingDB).filter_by(table_name=table_name, objectid=object_id)
)
object_mapping = result.scalars().first()
return str(object_mapping.uuid)
Loading