diff --git a/agenta-backend/agenta_backend/models/api/organization_models.py b/agenta-backend/agenta_backend/models/api/organization_models.py deleted file mode 100644 index 8dac03abd5..0000000000 --- a/agenta-backend/agenta_backend/models/api/organization_models.py +++ /dev/null @@ -1,30 +0,0 @@ -from datetime import datetime -from bson import ObjectId -from typing import Optional, List -from pydantic import BaseModel, Field - - -class TimestampModel(BaseModel): - created_at: datetime = Field(datetime.now()) - updated_at: datetime = Field(datetime.now()) - - -class Organization(BaseModel): - id: Optional[str] - name: str - description: Optional[str] - type: Optional[str] - owner: str - members: Optional[List[str]] - invitations: Optional[List] - is_paying: Optional[bool] - - -class OrganizationUpdate(BaseModel): - name: Optional[str] - description: Optional[str] - - -class OrganizationOutput(BaseModel): - id: str - name: str diff --git a/agenta-backend/agenta_backend/routers/organization_router.py b/agenta-backend/agenta_backend/routers/organization_router.py deleted file mode 100644 index 29036203b8..0000000000 --- a/agenta-backend/agenta_backend/routers/organization_router.py +++ /dev/null @@ -1,82 +0,0 @@ -"""Routes for image-related operations (push, remove). -Does not deal with the instanciation of the images -""" - -import os -import logging -from fastapi import HTTPException, Request -from agenta_backend.utils.common import APIRouter -from agenta_backend.services.selectors import get_user_own_org -from agenta_backend.models.api.organization_models import ( - OrganizationOutput, - Organization, -) -from agenta_backend.services import db_manager - -if os.environ["FEATURE_FLAG"] in ["cloud", "ee"]: - from agenta_backend.commons.services.selectors import ( - get_user_and_org_id, - ) # noqa pylint: disable-all -else: - from agenta_backend.services.selectors import get_user_and_org_id - - -router = APIRouter() -logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - - -@router.get("/", response_model=list[Organization], operation_id="list_organizations") -async def list_organizations( - request: Request, -): - """ - Returns a list of organizations associated with the user's session. - - Args: - stoken_session (SessionContainer): The user's session token. - - Returns: - list[Organization]: A list of organizations associated with the user's session. - - Raises: - HTTPException: If there is an error retrieving the organizations from the database. - """ - - try: - user_org_data: dict = await get_user_and_org_id(request.state.user_id) - organizations_db = await db_manager.get_organizations_by_list_ids( - user_org_data["organization_ids"] - ) - response = [ - Organization( - id=str(org.id), - name=str(org.name), - description=str(org.description), - owner=str(org.owner), - is_paying=org.is_paying, - ).dict(exclude_unset=True) - for org in organizations_db - ] - - return response - - except Exception as e: - raise HTTPException( - status_code=500, - detail=str(e), - ) - - -@router.get("/own/", response_model=OrganizationOutput, operation_id="get_own_org") -async def get_user_organization( - request: Request, -): - try: - user_org_data: dict = await get_user_and_org_id(request.state.user_id) - org_db = await get_user_own_org(user_org_data["uid"]) - if org_db is None: - raise HTTPException(404, detail="User does not have an organization") - return OrganizationOutput(id=str(org_db.id), name=org_db.name) - except Exception as e: - raise HTTPException(status_code=500, detail=str(e)) diff --git a/agenta-backend/agenta_backend/tasks/evaluations.py b/agenta-backend/agenta_backend/tasks/evaluations.py index 57a0cabc45..54069c5527 100644 --- a/agenta-backend/agenta_backend/tasks/evaluations.py +++ b/agenta-backend/agenta_backend/tasks/evaluations.py @@ -96,6 +96,9 @@ def evaluate( loop.run_until_complete(DBEngine().init_db()) app = loop.run_until_complete(fetch_app_by_id(app_id)) app_variant_db = loop.run_until_complete(fetch_app_variant_by_id(variant_id)) + assert ( + app_variant_db is not None + ), f"App variant with id {variant_id} not found!" app_variant_parameters = app_variant_db.config.parameters testset_db = loop.run_until_complete(fetch_testset_by_id(testset_id)) new_evaluation_db = loop.run_until_complete( diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 490866e05a..94caae0360 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -43,7 +43,7 @@ services: "--log-level", "info", "--root-path", - "/api", + "/api" ] labels: - "traefik.http.routers.backend.rule=PathPrefix(`/api/`)"