Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mmabrouk committed Jan 27, 2024
2 parents f493061 + a659d89 commit 303702e
Show file tree
Hide file tree
Showing 15 changed files with 646 additions and 679 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,23 @@ async def migrate_old_auto_evaluation_scenario_to_new_auto_evaluation_scenario(
EvaluationScenarioResult(
evaluator_config=PydanticObjectId(evaluator_config),
result=Result(
type="number"
if isinstance(old_scenario.score, int)
else "number"
if isinstance(old_scenario.score, float)
else "string"
if isinstance(old_scenario.score, str)
else "boolean"
if isinstance(old_scenario.score, bool)
else "any",
type=(
"number"
if isinstance(old_scenario.score, int)
else (
"number"
if isinstance(old_scenario.score, float)
else (
"string"
if isinstance(old_scenario.score, str)
else (
"boolean"
if isinstance(old_scenario.score, bool)
else "any"
)
)
)
),
value=old_scenario.score,
),
)
Expand Down
1 change: 1 addition & 0 deletions agenta-backend/agenta_backend/models/converters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Converts db models to pydantic models
"""

import json
from typing import List
from agenta_backend.services import db_manager
Expand Down
16 changes: 10 additions & 6 deletions agenta-backend/agenta_backend/routers/app_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,16 @@ async def create_app_and_variant_from_template(
app_variant_db = await app_manager.add_variant_based_on_image(
app=app,
variant_name="app.default",
docker_id_or_template_uri=template_db.template_uri
if os.environ["FEATURE_FLAG"] in ["cloud", "ee"]
else template_db.digest,
tags=f"{image_name}"
if os.environ["FEATURE_FLAG"] not in ["cloud", "ee"]
else None,
docker_id_or_template_uri=(
template_db.template_uri
if os.environ["FEATURE_FLAG"] in ["cloud", "ee"]
else template_db.digest
),
tags=(
f"{image_name}"
if os.environ["FEATURE_FLAG"] not in ["cloud", "ee"]
else None
),
base_name="app",
config_name="default",
is_template_image=True,
Expand Down
1 change: 1 addition & 0 deletions agenta-backend/agenta_backend/services/app_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Main Business logic
"""

import os
import logging
from urllib.parse import urlparse
Expand Down
8 changes: 5 additions & 3 deletions agenta-backend/agenta_backend/tasks/evaluations.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ def evaluate(
name=input_item["name"],
type="text",
value=data_point[
input_item["name"]
if input_item["type"] != "messages"
else "chat"
(
input_item["name"]
if input_item["type"] != "messages"
else "chat"
)
], # TODO: We need to remove the hardcoding of chat as name for chat inputs from the FE
)
for input_item in list_inputs
Expand Down
1,193 changes: 602 additions & 591 deletions agenta-backend/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion agenta-backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sentry-sdk = {extras = ["fastapi"], version = "^1.34.0"}
kubernetes = "^28.1.0"
celery = "^5.3.6"
watchdog = {extras = ["watchmedo"], version = "^3.0.0"}
beanie = {git = "https://github.com/mmabrouk/beanie"}
beanie = "^1.25.0"

[tool.poetry.group.dev.dependencies]
pytest = "^7.3.1"
Expand Down
2 changes: 0 additions & 2 deletions agenta-cli/agenta/cli/variant_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ def add_variant(
if tar_path.exists():
tar_path.unlink()

# docker_image: DockerImage = build_and_upload_docker_image(
# folder=app_path, app_name=app_name, variant_name=variant_name)
except Exception as ex:
click.echo(click.style(f"Error while building image: {ex}", fg="red"))
return None
Expand Down
61 changes: 0 additions & 61 deletions agenta-cli/agenta/docker/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,64 +99,3 @@ def ignore_patterns(path, names):

# dockerfile_path.unlink()
return tarfile_path


def build_and_upload_docker_image(
folder: Path, variant_name: str, app_name: str
) -> Image:
"""
DEPRECATED
Builds an image from the folder and returns the path
Arguments:
folder -- The folder containg the app code
Returns:
The image object
TODO: Check that the variant name does not exist
TODO: Deal with different app names (probably we need to look then at multiple tags)
TODO: Error handling
"""
# Initialize Docker client
client = docker.from_env()

with TemporaryDirectory() as temp_dir:
# Create a Dockerfile for the app
# TODO: Later do this in the temp dir
dockerfile_path = create_dockerfile(folder)
shutil.copytree(
Path(__file__).parent.parent / "sdk",
folder / "agenta",
)
shutil.copy(Path(__file__).parent / "docker-assets" / "main.py", folder)
shutil.copy(Path(__file__).parent / "docker-assets" / "entrypoint.sh", folder)

# Copy the app files to a temporary directory
shutil.copytree(folder, temp_dir, dirs_exist_ok=True)

# Build the Docker image
registry = settings.registry
tag = f"{registry}/{app_name.lower()}_{variant_name.lower()}:latest"
print("Building Docker image...")
try:
image, build_log = client.images.build(
path=temp_dir,
tag=tag,
buildargs={"ROOT_PATH": f"/{app_name}/{variant_name}"},
rm=True, # Remove intermediate containers after a successful build
)

except docker.errors.BuildError as ex:
logger.error("Error building Docker image:\n")
# Print the build log
for line in ex.build_log:
logger.error(line)
raise ex
# Upload the Docker image to the Agenta registry
print("Uploading Docker image...")
client.images.push(repository=f"{registry}", tag="latest")
print("Docker image uploaded successfully.")

# Clean up the temporary Dockerfile
dockerfile_path.unlink()
return image
4 changes: 3 additions & 1 deletion agenta-cli/agenta/sdk/agenta_decorator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The code for the Agenta SDK"""

import os
import sys
import time
Expand Down Expand Up @@ -184,9 +185,10 @@ async def execute_function(
def handle_exception(e: Exception) -> JSONResponse:
"""Handle exceptions and return a JSONResponse."""

status_code: int = e.status_code if hasattr(e, "status_code") else 500
traceback_str = traceback.format_exception(e, value=e, tb=e.__traceback__)
return JSONResponse(
status_code=500,
status_code=status_code,
content={"error": str(e), "traceback": "".join(traceback_str)},
)

Expand Down
2 changes: 1 addition & 1 deletion agenta-cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "agenta"
version = "0.8.2"
version = "0.8.4"
description = "The SDK for agenta is an open-source LLMOps platform."
readme = "README.md"
authors = ["Mahmoud Mabrouk <[email protected]>"]
Expand Down
Binary file modified agenta-web/public/assets/favicon.ico
Binary file not shown.
3 changes: 2 additions & 1 deletion agenta-web/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {useProfileData} from "@/contexts/profile.context"
import {getColorFromStr} from "@/lib/helpers/colors"
import {getInitials, isDemo} from "@/lib/helpers/utils"
import {useSession} from "@/hooks/useSession"
import {useLocalStorage} from "usehooks-ts"

type StyleProps = {
themeMode: "system" | "dark" | "light"
Expand Down Expand Up @@ -138,7 +139,7 @@ const Sidebar: React.FC = () => {
}
const [selectedKeys, setSelectedKeys] = useState(initialSelectedKeys)
const {user, orgs, selectedOrg, changeSelectedOrg, reset} = useProfileData()
const [collapsed, setCollapsed] = useState(false)
const [collapsed, setCollapsed] = useLocalStorage("sidebarCollapsed", false)

useEffect(() => {
setSelectedKeys(initialSelectedKeys)
Expand Down
Binary file modified docs/logo/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
},
"favicon": "/logo/favicon.png",
"colors": {
"primary": "#34d399",
"light": "#34d399",
"dark": "#34d399"
"primary": "#4AA081",
"light": "#4AA081",
"dark": "#4AA081"
},
"modeToggle": {
"default": "light",
Expand Down

0 comments on commit 303702e

Please sign in to comment.