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

Function create_app_and_envs

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

Create a new app with the given name and organization ID. Args: app_name (str): The name of the app to create. project_id (str): The ID of the project. Returns: AppDB: The created app. Raises: ValueError: If an app with the same name already exists

(
    app_name: str,
    template_key: Optional[str] = None,
    project_id: Optional[str] = None,
)

Source from the content-addressed store, hash-verified

597
598
599async def create_app_and_envs(
600 app_name: str,
601 template_key: Optional[str] = None,
602 project_id: Optional[str] = None,
603) -> AppDB:
604 """
605 Create a new app with the given name and organization ID.
606
607 Args:
608 app_name (str): The name of the app to create.
609 project_id (str): The ID of the project.
610
611 Returns:
612 AppDB: The created app.
613
614 Raises:
615 ValueError: If an app with the same name already exists.
616 """
617
618 app = await fetch_app_by_name_and_parameters(
619 app_name=app_name, project_id=project_id
620 )
621 if app is not None:
622 raise ValueError("App with the same name already exists")
623
624 app_type = await get_app_type(
625 template_key=template_key,
626 )
627
628 async with engine.core_session() as session:
629 app = AppDB(
630 app_name=app_name, project_id=uuid.UUID(project_id), app_type=app_type
631 )
632
633 session.add(app)
634 await session.commit()
635 await session.refresh(app)
636
637 await initialize_environments(session=session, app_db=app)
638 return app
639
640
641async def update_app(app_id: str, values_to_update: dict) -> None:

Callers

nothing calls this directly

Calls 7

AppDBClass · 0.90
get_app_typeFunction · 0.85
initialize_environmentsFunction · 0.85
core_sessionMethod · 0.80
addMethod · 0.80
commitMethod · 0.45

Tested by

no test coverage detected