Skip to content

Commit e5e086d

Browse files
authored
Merge pull request #1851 from Agenta-AI/refactor/add-function-to-fetch-corresponding-object-uuid
Refactor/add function to fetch corresponding object UUID
2 parents 46cd3f8 + 233f7ef commit e5e086d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

agenta-backend/agenta_backend/services/db_manager.py

+21
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
)
6464
from agenta_backend.models.db_models import (
6565
TemplateDB,
66+
IDsMappingDB,
6667
AppVariantRevisionsDB,
6768
HumanEvaluationVariantDB,
6869
EvaluationScenarioResultDB,
@@ -3094,3 +3095,23 @@ async def check_if_evaluation_contains_failed_evaluation_scenarios(
30943095
if not count:
30953096
return False
30963097
return count > 0
3098+
3099+
3100+
async def fetch_corresponding_object_uuid(table_name: str, object_id: str) -> str:
3101+
"""
3102+
Fetches a corresponding object uuid.
3103+
3104+
Args:
3105+
table_name (str): The table name
3106+
object_id (str): The object identifier
3107+
3108+
Returns:
3109+
The corresponding object uuid as string.
3110+
"""
3111+
3112+
async with db_engine.get_session() as session:
3113+
result = await session.execute(
3114+
select(IDsMappingDB).filter_by(table_name=table_name, objectid=object_id)
3115+
)
3116+
object_mapping = result.scalars().first()
3117+
return str(object_mapping.uuid)

0 commit comments

Comments
 (0)