From c56653bfcd92f03ef80a5e3b66d44137dbbf8668 Mon Sep 17 00:00:00 2001 From: LucasTrg <47852577+LucasTrg@users.noreply.github.com> Date: Wed, 22 May 2024 09:39:59 +0200 Subject: [PATCH 1/3] Fixes local URI for deployments --- .../agenta_backend/services/deployment_manager.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/agenta-backend/agenta_backend/services/deployment_manager.py b/agenta-backend/agenta_backend/services/deployment_manager.py index 4c3f803ac..c17a404f3 100644 --- a/agenta-backend/agenta_backend/services/deployment_manager.py +++ b/agenta-backend/agenta_backend/services/deployment_manager.py @@ -147,4 +147,17 @@ async def validate_image(image: Image) -> bool: def get_deployment_uri(deployment: DeploymentDB) -> str: - return deployment.uri.replace("http://localhost", "http://host.docker.internal") + """ + Builds a URI allowing the backend to access a given deployment. + In the case of a self-hosted setup, we bypass traefik and use the docker generated dns entry instead. + + Args: + deployment (DeploymentDB): The deployment to reach. + + Returns: + str: URI leading to the deployment + """ + if "localhost" in deployment.uri: + # the DNS entry automatically created by docker for the container are the first 12 characters of the container's id + return "http://"+deployment.container_id[:12] + return deployment.uri From e0c6c92f971046cd1f616ca5aa246dd4db8e8740 Mon Sep 17 00:00:00 2001 From: LucasTrg <47852577+LucasTrg@users.noreply.github.com> Date: Wed, 22 May 2024 09:46:04 +0200 Subject: [PATCH 2/3] Fixes typo --- .../agenta_backend/services/deployment_manager.py | 6 +++--- agenta-backend/agenta_backend/services/llm_apps_service.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/agenta-backend/agenta_backend/services/deployment_manager.py b/agenta-backend/agenta_backend/services/deployment_manager.py index c17a404f3..32cf015e1 100644 --- a/agenta-backend/agenta_backend/services/deployment_manager.py +++ b/agenta-backend/agenta_backend/services/deployment_manager.py @@ -149,15 +149,15 @@ async def validate_image(image: Image) -> bool: def get_deployment_uri(deployment: DeploymentDB) -> str: """ Builds a URI allowing the backend to access a given deployment. - In the case of a self-hosted setup, we bypass traefik and use the docker generated dns entry instead. + In the case of a self-hosted setup, we bypass traefik and use the docker generated dns entry instead. Args: deployment (DeploymentDB): The deployment to reach. Returns: - str: URI leading to the deployment + str: URI leading to the deployment. """ if "localhost" in deployment.uri: # the DNS entry automatically created by docker for the container are the first 12 characters of the container's id - return "http://"+deployment.container_id[:12] + return "http://" + deployment.container_id[:12] return deployment.uri diff --git a/agenta-backend/agenta_backend/services/llm_apps_service.py b/agenta-backend/agenta_backend/services/llm_apps_service.py index 2accbfe50..594f5a50c 100644 --- a/agenta-backend/agenta_backend/services/llm_apps_service.py +++ b/agenta-backend/agenta_backend/services/llm_apps_service.py @@ -274,7 +274,7 @@ async def get_parameters_from_openapi(uri: str) -> List[Dict]: """ - schema = await _get_openai_json_from_uri(uri) + schema = await _get_openapi_json_from_uri(uri) try: body_schema_name = ( @@ -304,7 +304,7 @@ async def get_parameters_from_openapi(uri: str) -> List[Dict]: return parameters -async def _get_openai_json_from_uri(uri): +async def _get_openapi_json_from_uri(uri): async with aiohttp.ClientSession() as client: resp = await client.get(uri, timeout=5) resp_text = await resp.text() From a5a944f36efc8a057baeffef70be024b7f7639bb Mon Sep 17 00:00:00 2001 From: Abram Date: Tue, 10 Sep 2024 16:06:48 +0100 Subject: [PATCH 3/3] refactor (backend): resolve TypeError: get_deployment_uri() got an unexpected keyword argument 'uri' --- agenta-backend/agenta_backend/services/deployment_manager.py | 4 +--- agenta-backend/agenta_backend/tasks/evaluations.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/agenta-backend/agenta_backend/services/deployment_manager.py b/agenta-backend/agenta_backend/services/deployment_manager.py index 2c1ae4942..f93e0a247 100644 --- a/agenta-backend/agenta_backend/services/deployment_manager.py +++ b/agenta-backend/agenta_backend/services/deployment_manager.py @@ -163,9 +163,7 @@ def get_deployment_uri(deployment: DeploymentDB) -> str: Returns: str: URI leading to the deployment. """ - if "localhost" in deployment.uri: - # the DNS entry automatically created by docker for the container - # are the first 12 characters of the container's id + # the DNS entry automatically created by docker for the container are the first 12 characters of the container's id return "http://" + deployment.container_id[:12] return deployment.uri diff --git a/agenta-backend/agenta_backend/tasks/evaluations.py b/agenta-backend/agenta_backend/tasks/evaluations.py index b563bdc20..1c548caee 100644 --- a/agenta-backend/agenta_backend/tasks/evaluations.py +++ b/agenta-backend/agenta_backend/tasks/evaluations.py @@ -120,7 +120,7 @@ def evaluate( deployment_db = loop.run_until_complete( get_deployment_by_id(str(app_variant_db.base.deployment_id)) ) - uri = deployment_manager.get_deployment_uri(uri=deployment_db.uri) # type: ignore + uri = deployment_manager.get_deployment_uri(deployment_db) # type: ignore # 2. Initialize vars evaluators_aggregated_data = {