MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / __call__

Method __call__

app/api/agentops/deploy/views/deploy.py:397–433  ·  view source on GitHub ↗

Delete a deployment for a project. This will remove the HostingProjectModel record and clean up any associated resources.

(
        self,
        project_id: str,
        orm: Session = Depends(get_orm_session),
    )

Source from the content-addressed store, hash-verified

395
396class DeleteDeploymentView(BaseDeploymentView):
397 async def __call__(
398 self,
399 project_id: str,
400 orm: Session = Depends(get_orm_session),
401 ) -> StatusResponse:
402 """
403 Delete a deployment for a project.
404
405 This will remove the HostingProjectModel record and clean up any associated resources.
406 """
407 project: HostingProjectModel = await self.get_hosting_project(orm, project_id)
408
409 # Delete all Kubernetes resources associated with the deployment
410 # This includes deployments, services, ingress, and secrets
411 deployment_name = project_id # Use project_id as deployment name
412 namespace = project.namespace
413
414 try:
415 success = delete_deployment_resources(
416 namespace=namespace, deployment_name=deployment_name, deployment_id=project_id
417 )
418
419 if not success:
420 logger.warning(f"Some Kubernetes resources failed to delete for project {project_id}")
421 # Continue with database deletion even if k8s cleanup had issues
422 except Exception as e:
423 logger.error(f"Error during Kubernetes cleanup for project {project_id}: {e}")
424 # Continue with database deletion even if k8s cleanup failed
425
426 # Delete the HostingProjectModel record
427 orm.delete(project)
428 orm.commit()
429
430 return StatusResponse(
431 success=True,
432 message="Deployment deleted successfully",
433 )

Callers

nothing calls this directly

Calls 4

StatusResponseClass · 0.90
get_hosting_projectMethod · 0.80
deleteMethod · 0.45

Tested by

no test coverage detected