Skip to content

Commit

Permalink
Merge pull request #1251 from romainrbr/fix-migration-simplification
Browse files Browse the repository at this point in the history
fix: simplify migration process
  • Loading branch information
mmabrouk authored Jan 23, 2024
2 parents 83272bd + e806ef4 commit b0cb158
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 41 deletions.
10 changes: 4 additions & 6 deletions agenta-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
15 changes: 10 additions & 5 deletions agenta-backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 = "^1.24.0"
beanie = {git = "https://github.com/mmabrouk/beanie"}

[tool.poetry.group.dev.dependencies]
pytest = "^7.3.1"
Expand Down
32 changes: 3 additions & 29 deletions docs/self-host/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/mmabrouk/beanie>
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 .
```

<Warning>
Make sure to replace `username`, `password`, and other relevant placeholders with your actual credentials, unless you're using default settings.
</Warning>

0 comments on commit b0cb158

Please sign in to comment.