Skip to content

Commit

Permalink
Merge pull request #1535 from Agenta-AI/remove-config-files
Browse files Browse the repository at this point in the history
remove all config files and rely on env vars
  • Loading branch information
aakrem authored Apr 19, 2024
2 parents b003005 + 0b54c50 commit 22261a7
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 42 deletions.
25 changes: 0 additions & 25 deletions agenta-backend/agenta_backend/config.py

This file was deleted.

4 changes: 0 additions & 4 deletions agenta-backend/agenta_backend/config.toml

This file was deleted.

1 change: 0 additions & 1 deletion agenta-backend/agenta_backend/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
from contextlib import asynccontextmanager

from agenta_backend.config import settings
from agenta_backend import celery_config
from agenta_backend.routers import (
app_router,
Expand Down
5 changes: 3 additions & 2 deletions agenta-backend/agenta_backend/routers/app_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from fastapi import HTTPException, Request
from beanie import PydanticObjectId as ObjectId

from agenta_backend.config import settings
from agenta_backend.models import converters
from agenta_backend.utils.common import (
isEE,
Expand Down Expand Up @@ -78,6 +77,8 @@
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

registry_repo_name = os.environ.get("REGISTRY_REPO_NAME")


@router.get(
"/{app_id}/variants/",
Expand Down Expand Up @@ -341,7 +342,7 @@ async def add_variant_from_image(
docker_id=payload.docker_id,
tags=payload.tags,
)
if not payload.tags.startswith(settings.registry):
if not payload.tags.startswith(registry_repo_name):
raise HTTPException(
status_code=500,
detail="Image should have a tag starting with the registry name (agenta-server)",
Expand Down
5 changes: 3 additions & 2 deletions agenta-backend/agenta_backend/services/deployment_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
from typing import Dict

from agenta_backend.config import settings
from agenta_backend.utils.common import isCloudEE
from agenta_backend.models.api.api_models import Image
from agenta_backend.models.db_models import AppVariantDB, DeploymentDB, ImageDB
Expand All @@ -12,6 +11,8 @@
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

agenta_template_repo = os.getenv("AGENTA_TEMPLATE_REPO")


async def start_service(
app_variant_db: AppVariantDB, env_vars: Dict[str, str]
Expand Down Expand Up @@ -133,7 +134,7 @@ async def validate_image(image: Image) -> bool:
msg = "Image tags cannot be empty"
logger.error(msg)
raise ValueError(msg)
if not image.tags.startswith(settings.registry):
if not image.tags.startswith(agenta_template_repo):
raise ValueError(
"Image should have a tag starting with the registry name (agenta-server)"
)
Expand Down
5 changes: 3 additions & 2 deletions agenta-backend/agenta_backend/services/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from typing import List

import docker
from agenta_backend.config import settings
from agenta_backend.models.api.api_models import (
Image,
DockerEnvVars,
Dict,
)

agenta_template_repo = os.getenv("AGENTA_TEMPLATE_REPO")

client = docker.from_env()

# Set up logging
Expand Down Expand Up @@ -55,7 +56,7 @@ def list_images() -> List[Image]:
registry_images = [
Image(type="image", docker_id=image.id, tags=image.tags[0])
for image in all_images
if len(image.tags) > 0 and image.tags[0].startswith(settings.registry)
if len(image.tags) > 0 and image.tags[0].startswith(agenta_template_repo)
]
return registry_images

Expand Down
9 changes: 3 additions & 6 deletions agenta-backend/agenta_backend/services/templates_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import httpx
import backoff

from typing import Any, Dict, List
from typing import Any, Dict, List, Union
from asyncio.exceptions import CancelledError
from httpx import ConnectError, TimeoutException

from agenta_backend.config import settings
from agenta_backend.utils import redis_utils
from agenta_backend.services import db_manager
from agenta_backend.utils.common import isCloud, isOss
Expand All @@ -17,8 +15,7 @@

templates_base_url = os.getenv("TEMPLATES_BASE_URL")
agenta_template_repo = os.getenv("AGENTA_TEMPLATE_REPO")

from typing import Union
docker_hub_url = os.getenv("DOCKER_HUB_URL")


async def update_and_sync_templates(cache: bool = True) -> None:
Expand Down Expand Up @@ -87,7 +84,7 @@ async def retrieve_templates_from_dockerhub_cached(cache: bool) -> List[dict]:

# If not cached, fetch data from Docker Hub and cache it in Redis
response = await retrieve_templates_from_dockerhub(
settings.docker_hub_url,
docker_hub_url,
agenta_template_repo,
)
response_data = response["results"]
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.gh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ services:
- CELERY_BROKER_URL=amqp://guest@rabbitmq//
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- TEMPLATES_BASE_URL=https://llm-app-json.s3.eu-central-1.amazonaws.com
- REGISTRY_REPO_NAME=agentaai
- DOCKER_HUB_URL=https://hub.docker.com/v2/repositories
command:
[
"uvicorn",
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ services:
- CELERY_BROKER_URL=amqp://guest@rabbitmq//
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- TEMPLATES_BASE_URL=https://llm-app-json.s3.eu-central-1.amazonaws.com
- REGISTRY_REPO_NAME=agentaai
- DOCKER_HUB_URL=https://hub.docker.com/v2/repositories
volumes:
- ./agenta-backend/agenta_backend:/app/agenta_backend
- ./agenta-backend/tests:/app/tests
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ services:
- AGENTA_TEMPLATE_REPO=agentaai/templates_v2
- POSTHOG_API_KEY=phc_hmVSxIjTW1REBHXgj2aw4HW9X6CXb6FzerBgP9XenC7
- TEMPLATES_BASE_URL=https://llm-app-json.s3.eu-central-1.amazonaws.com
- REGISTRY_REPO_NAME=agentaai
- DOCKER_HUB_URL=https://hub.docker.com/v2/repositories
volumes:
- ./agenta-backend/agenta_backend:/app/agenta_backend
- ./agenta-backend/tests:/app/tests
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ services:
- CELERY_BROKER_URL=amqp://guest@rabbitmq//
- CELERY_RESULT_BACKEND=redis://redis:6379/0
- TEMPLATES_BASE_URL=https://llm-app-json.s3.eu-central-1.amazonaws.com
- REGISTRY_REPO_NAME=agentaai
- DOCKER_HUB_URL=https://hub.docker.com/v2/repositories
volumes:
- ./agenta-backend/agenta_backend:/app/agenta_backend
- ./agenta-backend/tests:/app/tests
Expand Down

0 comments on commit 22261a7

Please sign in to comment.