From f0dbb4902899dbf3b1f24bc67003c460ba050263 Mon Sep 17 00:00:00 2001 From: Akrem Abayed Date: Tue, 23 Jan 2024 12:03:51 +0100 Subject: [PATCH 1/2] fix for all aggregated results --- agenta-backend/agenta_backend/tasks/evaluations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agenta-backend/agenta_backend/tasks/evaluations.py b/agenta-backend/agenta_backend/tasks/evaluations.py index dea2ee5a42..cfb130621f 100644 --- a/agenta-backend/agenta_backend/tasks/evaluations.py +++ b/agenta-backend/agenta_backend/tasks/evaluations.py @@ -88,7 +88,7 @@ def evaluate( # 2. Initialize vars evaluators_aggregated_data = { str(evaluator_config_db.id): { - "evaluator_key": evaluator_config.evaluator_key, + "evaluator_key": evaluator_config_db.evaluator_key, "results": [], } for evaluator_config_db in evaluator_config_dbs From e806ef4547633cde9fe095d6ed5179db9889b62b Mon Sep 17 00:00:00 2001 From: Romain Brucker Date: Tue, 23 Jan 2024 11:58:14 +0100 Subject: [PATCH 2/2] fix: changing beanie source to mmabrouk's repo chore(doc): simplifying migration process fix: removing unneeded docker run command --- agenta-backend/Dockerfile | 10 ++++------ agenta-backend/poetry.lock | 15 ++++++++++----- agenta-backend/pyproject.toml | 2 +- docs/self-host/migration.mdx | 32 +++----------------------------- 4 files changed, 18 insertions(+), 41 deletions(-) diff --git a/agenta-backend/Dockerfile b/agenta-backend/Dockerfile index 934d2eebcf..0f7eec3b78 100644 --- a/agenta-backend/Dockerfile +++ b/agenta-backend/Dockerfile @@ -3,6 +3,10 @@ FROM python:3.9-slim-buster WORKDIR /app +# Install git and clone the necessary repository +RUN apt-get update -y \ + && apt-get install -y git + # Ensure pip and poetry are up to date RUN pip install --upgrade pip \ && pip install poetry @@ -18,12 +22,6 @@ RUN touch /app/agenta_backend/__init__.py RUN poetry config virtualenvs.create false \ && poetry install --no-interaction --no-ansi -# Install git and clone the necessary repository -RUN apt-get update -y \ - && apt-get install -y git \ - && git clone https://github.com/mmabrouk/beanie \ - && cd beanie && pip install . - # remove dummy module RUN rm -r /app/agenta_backend EXPOSE 8000 \ No newline at end of file diff --git a/agenta-backend/poetry.lock b/agenta-backend/poetry.lock index 667aef2447..40dbafea7a 100644 --- a/agenta-backend/poetry.lock +++ b/agenta-backend/poetry.lock @@ -252,10 +252,8 @@ version = "1.24.0" description = "Asynchronous Python ODM for MongoDB" optional = false python-versions = ">=3.7,<4.0" -files = [ - {file = "beanie-1.24.0-py3-none-any.whl", hash = "sha256:d48b047c9640d8b4312b781254fcf808ad03262321f1793cf1228972953e3649"}, - {file = "beanie-1.24.0.tar.gz", hash = "sha256:2328f0f745ea8b4626a818c79ed71021a5c4362fc2c0adc48a59e6b40c5ce54b"}, -] +files = [] +develop = false [package.dependencies] click = ">=7" @@ -270,6 +268,12 @@ doc = ["Markdown (>=3.3)", "Pygments (>=2.8.0)", "jinja2 (>=3.0.3)", "mkdocs (>= queue = ["beanie-batteries-queue (>=0.2)"] test = ["asgi-lifespan (>=1.0.1)", "dnspython (>=2.1.0)", "fastapi (>=0.100)", "flake8 (>=3)", "httpx (>=0.23.0)", "pre-commit (>=2.3.0)", "pydantic-extra-types (>=2)", "pydantic-settings (>=2)", "pydantic[email]", "pyright (>=0)", "pytest (>=6.0.0)", "pytest-asyncio (>=0.21.0)", "pytest-cov (>=2.8.1)"] +[package.source] +type = "git" +url = "https://github.com/mmabrouk/beanie" +reference = "HEAD" +resolved_reference = "887e0bea1345bcfc0c553165790477c26e9dede7" + [[package]] name = "billiard" version = "4.2.0" @@ -1936,6 +1940,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -2742,4 +2747,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "3e56ee6faaabfce258cd4e14ba22a97bc24336a120e20d5df94342be7fb47427" +content-hash = "932d734587e575453e6e2df1186f85e924ca4c5b8cf9753b375f41e61633310a" diff --git a/agenta-backend/pyproject.toml b/agenta-backend/pyproject.toml index 392395de7a..4fa6863d73 100644 --- a/agenta-backend/pyproject.toml +++ b/agenta-backend/pyproject.toml @@ -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 = "^1.24.0" +beanie = {git = "https://github.com/mmabrouk/beanie"} [tool.poetry.group.dev.dependencies] pytest = "^7.3.1" diff --git a/docs/self-host/migration.mdx b/docs/self-host/migration.mdx index 41258214a3..502caa8c13 100644 --- a/docs/self-host/migration.mdx +++ b/docs/self-host/migration.mdx @@ -9,42 +9,16 @@ To upgrade to the latest version of Agenta, execute the following command: ``` docker compose -f docker-compose.gh.yml up -d --pull always - ``` This command instructs Docker to fetch and use the latest version of the Agenta image. -## Database Migration with Beanie - -This guide offers detailed steps for performing database migrations in the Agenta backend system, using Beanie, a MongoDB ODM (Object Document Mapper) for Python. You can learn more about Beanie [here](https://github.com/roman-right/beanie). - -### Setting Up Beanie - -To install a custom version of Beanie: - -``` -git clone -cd beanie -pip install . - -``` ### Migrating from Version 0.7 to 0.8 -1. **Accessing the Migration Directory**: First, navigate to the migration directory: +1. **Executing the Beanie Migration**: Run the migration script as follows: ``` - cd agenta_backend/migrations/17_01_24_pydantic_and_evaluations - - ``` - -2. **Executing the Beanie Migration**: Run the migration script as follows: - + docker compose exec -w /app/agenta_backend/migrations/17_01_24_pydantic_and_evaluations/ agenta-backend bash -c 'beanie migrate --no-use-transaction -uri $MONGODB_URI -db 'agenta_v2' -p .' ``` - beanie migrate --no-use-transaction -uri 'mongodb://username:password@localhost' -db 'agenta_v2' -p . - - ``` - - - Make sure to replace `username`, `password`, and other relevant placeholders with your actual credentials, unless you're using default settings. - \ No newline at end of file + \ No newline at end of file