MCPcopy
hub / github.com/Agenta-AI/agenta / update_app

Function update_app

api/oss/src/services/db_manager.py:641–678  ·  view source on GitHub ↗

Update the app in the database. Arguments: app_id (str): The app id values_to_update (dict): The values to update in the app

(app_id: str, values_to_update: dict)

Source from the content-addressed store, hash-verified

639
640
641async def update_app(app_id: str, values_to_update: dict) -> None:
642 """Update the app in the database.
643
644 Arguments:
645 app_id (str): The app id
646 values_to_update (dict): The values to update in the app
647 """
648
649 async with engine.core_session() as session:
650 result = await session.execute(select(AppDB).filter_by(id=uuid.UUID(app_id)))
651 app = result.scalars().first()
652 if not app:
653 raise NoResultFound(f"App with {app_id} not found")
654
655 # Check if 'app_name' is in the values to update
656 if "app_name" in values_to_update:
657 new_app_name = values_to_update["app_name"]
658
659 # Check if another app with the same name exists for the user
660 existing_app_result = await session.execute(
661 select(AppDB)
662 .filter(
663 AppDB.project_id == app.project_id
664 ) # Assuming 'user_id' exists on the AppDB model
665 .filter(AppDB.app_name == new_app_name)
666 )
667 existing_app = existing_app_result.scalars().first()
668
669 if existing_app:
670 raise Exception(
671 f"Cannot update app name to '{new_app_name}' because another app with this name already exists."
672 )
673
674 for key, value in values_to_update.items():
675 if hasattr(app, key):
676 setattr(app, key, value)
677
678 await session.commit()
679
680
681async def get_deployment_by_id(deployment_id: str) -> DeploymentDB:

Callers

nothing calls this directly

Calls 2

core_sessionMethod · 0.80
commitMethod · 0.45

Tested by

no test coverage detected