Fetches a base by its ID. Args: base_id (str): The ID of the base to fetch. Returns: VariantBaseDB: The fetched base, or None if no base was found.
(base_id: str)
| 345 | |
| 346 | |
| 347 | async def fetch_base_by_id(base_id: str) -> Optional[VariantBaseDB]: |
| 348 | """ |
| 349 | Fetches a base by its ID. |
| 350 | |
| 351 | Args: |
| 352 | base_id (str): The ID of the base to fetch. |
| 353 | |
| 354 | Returns: |
| 355 | VariantBaseDB: The fetched base, or None if no base was found. |
| 356 | """ |
| 357 | |
| 358 | assert base_id is not None, "no base_id provided" |
| 359 | base_uuid = await get_object_uuid(object_id=base_id, table_name="bases") |
| 360 | async with engine.core_session() as session: |
| 361 | result = await session.execute( |
| 362 | select(VariantBaseDB) |
| 363 | .options(joinedload(VariantBaseDB.deployment)) |
| 364 | .filter_by(id=uuid.UUID(base_uuid)) |
| 365 | ) |
| 366 | base = result.scalars().first() |
| 367 | if base is None: |
| 368 | raise NoResultFound(f"Base with id {base_id} not found") |
| 369 | return base |
| 370 | |
| 371 | |
| 372 | async def fetch_app_variant_by_name_and_appid( |
no test coverage detected