AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
tweak(rnd,docker) Remove SQLite (#7966)
Aarushi5000aa7ee01b
diff --git a/.dockerignore b/.dockerignoreindex 9a2289cf98..189c211919 100644--- a/.dockerignore+++ b/.dockerignore@@ -34,5 +34,6 @@ rnd/autogpt_builder/.next/rnd/autogpt_builder/node_modulesrnd/autogpt_builder/.env.examplernd/autogpt_builder/.env.local+rnd/autogpt_server/.envdiff --git a/.github/workflows/autogpt-server-ci.yml b/.github/workflows/autogpt-server-ci.ymlindex 12c4141d6c..f71f1a8aee 100644--- a/.github/workflows/autogpt-server-ci.yml+++ b/.github/workflows/autogpt-server-ci.yml@@ -31,12 +31,10 @@ jobs:matrix:python-version: ["3.10"]platform-os: [ubuntu, macos, macos-arm64, windows]- db-platform: [postgres, sqlite]runs-on: ${{ matrix.platform-os != 'macos-arm64' && format('{0}-latest', matrix.platform-os) || 'macos-14' }}steps:- name: Setup PostgreSQL- if: matrix.db-platform == 'postgres'uses: ikalnytskyi/action-setup-postgres@v6with:username: ${{ secrets.DB_USER || 'postgres' }}@@ -116,23 +114,13 @@ jobs:- name: Install Python dependenciesrun: poetry install- - name: Generate Prisma Client (Postgres)- if: matrix.db-platform == 'postgres'- run: poetry run prisma generate --schema postgres/schema.prisma-- - name: Run Database Migrations (Postgres)- if: matrix.db-platform == 'postgres'- run: poetry run prisma migrate dev --schema postgres/schema.prisma --name updates- env:- CONNECTION_STR: ${{ steps.postgres.outputs.connection-uri }}-- - name: Generate Prisma Client (SQLite)- if: matrix.db-platform == 'sqlite'+ - name: Generate Prisma Clientrun: poetry run prisma generate- - name: Run Database Migrations (SQLite)- if: matrix.db-platform == 'sqlite'+ - name: Run Database Migrationsrun: poetry run prisma migrate dev --name updates+ env:+ CONNECTION_STR: ${{ steps.postgres.outputs.connection-uri }}- id: lintname: Run Linterdiff --git a/docs/content/server/setup.md b/docs/content/server/setup.mdindex 0146c0e224..8fe31bc139 100644--- a/docs/content/server/setup.md+++ b/docs/content/server/setup.md@@ -91,8 +91,7 @@ In order to setup the database, you need to run the following commands, in the s```shdocker compose up postgres -d- poetry run prisma migrate dev --schema postgres/schema.prisma- docker compose down+ poetry run prisma migrate dev```After deploying the migration, to ensure that the database schema is correctly mapped to your codebase, allowing the application to interact with the database properly, you need to generate the Prisma database model:diff --git a/rnd/autogpt_server/Dockerfile b/rnd/autogpt_server/Dockerfileindex dfde797309..eeb954e93a 100644--- a/rnd/autogpt_server/Dockerfile+++ b/rnd/autogpt_server/Dockerfile@@ -35,9 +35,6 @@ COPY rnd/autogpt_server/pyproject.toml rnd/autogpt_server/poetry.lock ./RUN poetry install --no-interaction --no-ansi-COPY rnd/autogpt_server/postgres/schema.prisma app/rnd/autogpt_server/schema.prisma-RUN poetry run prisma generate-COPY rnd/autogpt_server /app/rnd/autogpt_serverWORKDIR /app/rnd/autogpt_serverdiff --git a/rnd/autogpt_server/Dockerfile.ws b/rnd/autogpt_server/Dockerfile.wsindex dc2cf98ee5..084ff1f089 100644--- a/rnd/autogpt_server/Dockerfile.ws+++ b/rnd/autogpt_server/Dockerfile.ws@@ -35,9 +35,6 @@ COPY rnd/autogpt_server/pyproject.toml rnd/autogpt_server/poetry.lock ./RUN poetry install --no-interaction --no-ansi-COPY rnd/autogpt_server/postgres/schema.prisma app/rnd/autogpt_server/schema.prisma-RUN poetry run prisma generate-COPY rnd/autogpt_server /app/rnd/autogpt_serverWORKDIR /app/rnd/autogpt_serverdiff --git a/rnd/autogpt_server/README.md b/rnd/autogpt_server/README.mdindex 4184413791..b396e3eabc 100644--- a/rnd/autogpt_server/README.md+++ b/rnd/autogpt_server/README.md@@ -59,7 +59,7 @@ We use the Poetry to manage the dependencies. To set up the project, follow thes```shdocker compose up postgres -d- poetry run prisma migrate dev --schema postgres/schema.prisma+ poetry run prisma migrate dev```## Running The Server@@ -101,7 +101,7 @@ docker-compose down --volumes --remove-orphans && docker-compose up --force-recrTo run the tests:```sh-poetry run pytest+poetry run test```## Developmentdiff --git a/rnd/autogpt_server/docker-compose.test.yaml b/rnd/autogpt_server/docker-compose.test.yamlnew file mode 100644index 0000000000..c1ceac4f83--- /dev/null+++ b/rnd/autogpt_server/docker-compose.test.yaml@@ -0,0 +1,21 @@+version: "3"+services:+ postgres-test:+ image: ankane/pgvector:latest+ environment:+ - POSTGRES_USER=agpt_user+ - POSTGRES_PASSWORD=pass123+ - POSTGRES_DB=agpt_local+ healthcheck:+ test: pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB+ interval: 10s+ timeout: 5s+ retries: 5+ ports:+ - "5433:5432"+ networks:+ - app-network-test++networks:+ app-network-test:+ driver: bridgediff --git a/rnd/autogpt_server/linter.py b/rnd/autogpt_server/linter.pyindex 5127b377a5..83c574b034 100644--- a/rnd/autogpt_server/linter.py+++ b/rnd/autogpt_server/linter.py@@ -1,5 +1,4 @@import os-import reimport subprocessdirectory = os.path.dirname(os.path.realpath(__file__))@@ -20,43 +19,9 @@ def lint():print("Lint failed, try running `poetry run format` to fix the issues: ", e)raise e- try:- run("schema_lint")- except subprocess.CalledProcessError as e:- print("Lint failed, try running `poetry run schema` to fix the issues: ", e)- raise e-def format():run("ruff", "check", "--fix", ".")run("isort", "--profile", "black", ".")run("black", ".")run("pyright", ".")---def schema():- file = os.path.join(directory, "schema.prisma")- text = open(file, "r").read()- text = re.sub(r'provider\s+=\s+".*"', 'provider = "postgresql"', text, 1)- text = re.sub(r'url\s+=\s+".*"', 'url = env("DATABASE_URL")', text, 1)- text = "// THIS FILE IS AUTO-GENERATED, RUN `poetry run schema` TO UPDATE\n" + text- with open(os.path.join(directory, "postgres", "schema.prisma"), "w") as f:- f.write(text)-- run("prisma", "format", "--schema", "schema.prisma")- run("prisma", "format", "--schema", "postgres/schema.prisma")- run("prisma", "migrate", "dev", "--schema", "schema.prisma")- run("prisma", "migrate", "dev", "--schema", "postgres/schema.prisma")---def schema_lint():- def read_schema(path: str) -> list[str]:- with open(path, "r") as f:- return [v for v in f.read().splitlines() if not v.startswith("//")]-- sqlite_schema = read_schema(os.path.join(directory, "schema.prisma"))- postgres_schema = read_schema(os.path.join(directory, "postgres", "schema.prisma"))- diff = [line.strip() for line in set(sqlite_schema) ^ set(postgres_schema)]-- if line := next((v for v in diff if not v.startswith(("provider", "url"))), None):- raise Exception(f"schema.prisma & postgres/schema.prisma mismatch: {line}")diff --git a/rnd/autogpt_server/postgres/migrations/20240722143307_migrations/migration.sql b/rnd/autogpt_server/migrations/20240722143307_migrations/migration.sqlsimilarity index 100%rename from rnd/autogpt_server/postgres/migrations/20240722143307_migrations/migration.sqlrename to rnd/autogpt_server/migrations/20240722143307_migrations/migration.sqldiff --git a/rnd/autogpt_server/migrations/20240722143555_migrations/migration.sql b/rnd/autogpt_server/migrations/20240722143555_migrations/migration.sqldeleted file mode 100644index 051d0a4472..0000000000--- a/rnd/autogpt_server/migrations/20240722143555_migrations/migration.sql+++ /dev/null@@ -1,94 +0,0 @@--- CreateTable-CREATE TABLE "AgentGraph" (- "id" TEXT NOT NULL,- "version" INTEGER NOT NULL DEFAULT 1,- "name" TEXT,- "description" TEXT,- "isActive" BOOLEAN NOT NULL DEFAULT true,- "isTemplate" BOOLEAN NOT NULL DEFAULT false,-- PRIMARY KEY ("id", "version")-);---- CreateTable-CREATE TABLE "AgentNode" (- "id" TEXT NOT NULL PRIMARY KEY,- "agentBlockId" TEXT NOT NULL,- "agentGraphId" TEXT NOT NULL,- "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,- "constantInput" TEXT NOT NULL DEFAULT '{}',- "metadata" TEXT NOT NULL DEFAULT '{}',- CONSTRAINT "AgentNode_agentBlockId_fkey" FOREIGN KEY ("agentBlockId") REFERENCES "AgentBlock" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "AgentNode_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph" ("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE-);---- CreateTable-CREATE TABLE "AgentNodeLink" (- "id" TEXT NOT NULL PRIMARY KEY,- "agentNodeSourceId" TEXT NOT NULL,- "sourceName" TEXT NOT NULL,- "agentNodeSinkId" TEXT NOT NULL,- "sinkName" TEXT NOT NULL,- CONSTRAINT "AgentNodeLink_agentNodeSourceId_fkey" FOREIGN KEY ("agentNodeSourceId") REFERENCES "AgentNode" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "AgentNodeLink_agentNodeSinkId_fkey" FOREIGN KEY ("agentNodeSinkId") REFERENCES "AgentNode" ("id") ON DELETE RESTRICT ON UPDATE CASCADE-);---- CreateTable-CREATE TABLE "AgentBlock" (- "id" TEXT NOT NULL PRIMARY KEY,- "name" TEXT NOT NULL,- "inputSchema" TEXT NOT NULL,- "outputSchema" TEXT NOT NULL-);---- CreateTable-CREATE TABLE "AgentGraphExecution" (- "id" TEXT NOT NULL PRIMARY KEY,- "agentGraphId" TEXT NOT NULL,- "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,- CONSTRAINT "AgentGraphExecution_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph" ("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE-);---- CreateTable-CREATE TABLE "AgentNodeExecution" (- "id" TEXT NOT NULL PRIMARY KEY,- "agentGraphExecutionId" TEXT NOT NULL,- "agentNodeId" TEXT NOT NULL,- "executionStatus" TEXT NOT NULL,- "addedTime" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,- "queuedTime" DATETIME,- "startedTime" DATETIME,- "endedTime" DATETIME,- CONSTRAINT "AgentNodeExecution_agentGraphExecutionId_fkey" FOREIGN KEY ("agentGraphExecutionId") REFERENCES "AgentGraphExecution" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "AgentNodeExecution_agentNodeId_fkey" FOREIGN KEY ("agentNodeId") REFERENCES "AgentNode" ("id") ON DELETE RESTRICT ON UPDATE CASCADE-);---- CreateTable-CREATE TABLE "AgentNodeExecutionInputOutput" (- "id" TEXT NOT NULL PRIMARY KEY,- "name" TEXT NOT NULL,- "data" TEXT NOT NULL,- "time" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,- "referencedByInputExecId" TEXT,- "referencedByOutputExecId" TEXT,- CONSTRAINT "AgentNodeExecutionInputOutput_referencedByInputExecId_fkey" FOREIGN KEY ("referencedByInputExecId") REFERENCES "AgentNodeExecution" ("id") ON DELETE SET NULL ON UPDATE CASCADE,- CONSTRAINT "AgentNodeExecutionInputOutput_referencedByOutputExecId_fkey" FOREIGN KEY ("referencedByOutputExecId") REFERENCES "AgentNodeExecution" ("id") ON DELETE SET NULL ON UPDATE CASCADE-);---- CreateTable-CREATE TABLE "AgentGraphExecutionSchedule" (- "id" TEXT NOT NULL PRIMARY KEY,- "agentGraphId" TEXT NOT NULL,- "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,- "schedule" TEXT NOT NULL,- "isEnabled" BOOLEAN NOT NULL DEFAULT true,- "inputData" TEXT NOT NULL,- "lastUpdated" DATETIME NOT NULL,- CONSTRAINT "AgentGraphExecutionSchedule_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph" ("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE-);---- CreateIndex-CREATE UNIQUE INDEX "AgentBlock_name_key" ON "AgentBlock"("name");---- CreateIndex-CREATE INDEX "AgentGraphExecutionSchedule_isEnabled_idx" ON "AgentGraphExecutionSchedule"("isEnabled");diff --git a/rnd/autogpt_server/migrations/20240724150133_node_input_unique_constraint/migration.sql b/rnd/autogpt_server/migrations/20240724150133_node_input_unique_constraint/migration.sqldeleted file mode 100644index 89e1567c29..0000000000--- a/rnd/autogpt_server/migrations/20240724150133_node_input_unique_constraint/migration.sql+++ /dev/null@@ -1,8 +0,0 @@-/*- Warnings:-- - A unique constraint covering the columns `[referencedByInputExecId,referencedByOutputExecId,name]` on the table `AgentNodeExecutionInputOutput` will be added. If there are existing duplicate values, this will fail.--*/--- CreateIndex-CREATE UNIQUE INDEX "AgentNodeExecutionInputOutput_referencedByInputExecId_referencedByOutputExecId_name_key" ON "AgentNodeExecutionInputOutput"("referencedByInputExecId", "referencedByOutputExecId", "name");diff --git a/rnd/autogpt_server/postgres/migrations/20240726131311_node_input_unique_constraint/migration.sql b/rnd/autogpt_server/migrations/20240726131311_node_input_unique_constraint/migration.sqlsimilarity index 100%rename from rnd/autogpt_server/postgres/migrations/20240726131311_node_input_unique_constraint/migration.sqlrename to rnd/autogpt_server/migrations/20240726131311_node_input_unique_constraint/migration.sqldiff --git a/rnd/autogpt_server/migrations/20240729051155_static_input_link/migration.sql b/rnd/autogpt_server/migrations/20240729051155_static_input_link/migration.sqldeleted file mode 100644index fa0ac70dc9..0000000000--- a/rnd/autogpt_server/migrations/20240729051155_static_input_link/migration.sql+++ /dev/null@@ -1,20 +0,0 @@--- AlterTable-ALTER TABLE "AgentNodeExecution" ADD COLUMN "executionData" TEXT;---- RedefineTables-PRAGMA foreign_keys=OFF;-CREATE TABLE "new_AgentNodeLink" (- "id" TEXT NOT NULL PRIMARY KEY,- "agentNodeSourceId" TEXT NOT NULL,- "sourceName" TEXT NOT NULL,- "agentNodeSinkId" TEXT NOT NULL,- "sinkName" TEXT NOT NULL,- "isStatic" BOOLEAN NOT NULL DEFAULT false,- CONSTRAINT "AgentNodeLink_agentNodeSourceId_fkey" FOREIGN KEY ("agentNodeSourceId") REFERENCES "AgentNode" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "AgentNodeLink_agentNodeSinkId_fkey" FOREIGN KEY ("agentNodeSinkId") REFERENCES "AgentNode" ("id") ON DELETE RESTRICT ON UPDATE CASCADE-);-INSERT INTO "new_AgentNodeLink" ("agentNodeSinkId", "agentNodeSourceId", "id", "sinkName", "sourceName") SELECT "agentNodeSinkId", "agentNodeSourceId", "id", "sinkName", "sourceName" FROM "AgentNodeLink";-DROP TABLE "AgentNodeLink";-ALTER TABLE "new_AgentNodeLink" RENAME TO "AgentNodeLink";-PRAGMA foreign_key_check;-PRAGMA foreign_keys=ON;diff --git a/rnd/autogpt_server/postgres/migrations/20240729061216_static_input_link/migration.sql b/rnd/autogpt_server/migrations/20240729061216_static_input_link/migration.sqlsimilarity index 100%rename from rnd/autogpt_server/postgres/migrations/20240729061216_static_input_link/migration.sqlrename to rnd/autogpt_server/migrations/20240729061216_static_input_link/migration.sqldiff --git a/rnd/autogpt_server/migrations/20240804040756_add_subgraph/migration.sql b/rnd/autogpt_server/migrations/20240804040756_add_subgraph/migration.sqldeleted file mode 100644index 5cc9e54f4a..0000000000--- a/rnd/autogpt_server/migrations/20240804040756_add_subgraph/migration.sql+++ /dev/null@@ -1,19 +0,0 @@--- RedefineTables-PRAGMA foreign_keys=OFF;-CREATE TABLE "new_AgentGraph" (- "id" TEXT NOT NULL,- "version" INTEGER NOT NULL DEFAULT 1,- "name" TEXT,- "description" TEXT,- "isActive" BOOLEAN NOT NULL DEFAULT true,- "isTemplate" BOOLEAN NOT NULL DEFAULT false,- "agentGraphParentId" TEXT,-- PRIMARY KEY ("id", "version"),- CONSTRAINT "AgentGraph_agentGraphParentId_version_fkey" FOREIGN KEY ("agentGraphParentId", "version") REFERENCES "AgentGraph" ("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE-);-INSERT INTO "new_AgentGraph" ("description", "id", "isActive", "isTemplate", "name", "version") SELECT "description", "id", "isActive", "isTemplate", "name", "version" FROM "AgentGraph";-DROP TABLE "AgentGraph";-ALTER TABLE "new_AgentGraph" RENAME TO "AgentGraph";-PRAGMA foreign_key_check;-PRAGMA foreign_keys=ON;diff --git a/rnd/autogpt_server/postgres/migrations/20240804040801_add_subgraph/migration.sql b/rnd/autogpt_server/migrations/20240804040801_add_subgraph/migration.sqlsimilarity index 100%rename from rnd/autogpt_server/postgres/migrations/20240804040801_add_subgraph/migration.sqlrename to rnd/autogpt_server/migrations/20240804040801_add_subgraph/migration.sqldiff --git a/rnd/autogpt_server/migrations/20240805115456_add_user_management/migration.sql b/rnd/autogpt_server/migrations/20240805115456_add_user_management/migration.sqldeleted file mode 100644index 36c213ad2f..0000000000--- a/rnd/autogpt_server/migrations/20240805115456_add_user_management/migration.sql+++ /dev/null@@ -1,60 +0,0 @@--- CreateTable-CREATE TABLE "User" (- "id" TEXT NOT NULL PRIMARY KEY,- "email" TEXT NOT NULL,- "name" TEXT,- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,- "updatedAt" DATETIME NOT NULL-);---- RedefineTables-PRAGMA foreign_keys=OFF;-CREATE TABLE "new_AgentGraph" (- "id" TEXT NOT NULL,- "version" INTEGER NOT NULL DEFAULT 1,- "name" TEXT,- "description" TEXT,- "isActive" BOOLEAN NOT NULL DEFAULT true,- "isTemplate" BOOLEAN NOT NULL DEFAULT false,- "userId" TEXT,- "agentGraphParentId" TEXT,-- PRIMARY KEY ("id", "version"),- CONSTRAINT "AgentGraph_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE,- CONSTRAINT "AgentGraph_agentGraphParentId_version_fkey" FOREIGN KEY ("agentGraphParentId", "version") REFERENCES "AgentGraph" ("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE-);-INSERT INTO "new_AgentGraph" ("agentGraphParentId", "description", "id", "isActive", "isTemplate", "name", "version") SELECT "agentGraphParentId", "description", "id", "isActive", "isTemplate", "name", "version" FROM "AgentGraph";-DROP TABLE "AgentGraph";-ALTER TABLE "new_AgentGraph" RENAME TO "AgentGraph";-CREATE TABLE "new_AgentGraphExecution" (- "id" TEXT NOT NULL PRIMARY KEY,- "agentGraphId" TEXT NOT NULL,- "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,- "userId" TEXT,- CONSTRAINT "AgentGraphExecution_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph" ("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "AgentGraphExecution_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE-);-INSERT INTO "new_AgentGraphExecution" ("agentGraphId", "agentGraphVersion", "id") SELECT "agentGraphId", "agentGraphVersion", "id" FROM "AgentGraphExecution";-DROP TABLE "AgentGraphExecution";-ALTER TABLE "new_AgentGraphExecution" RENAME TO "AgentGraphExecution";-CREATE TABLE "new_AgentGraphExecutionSchedule" (- "id" TEXT NOT NULL PRIMARY KEY,- "agentGraphId" TEXT NOT NULL,- "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,- "schedule" TEXT NOT NULL,- "isEnabled" BOOLEAN NOT NULL DEFAULT true,- "inputData" TEXT NOT NULL,- "lastUpdated" DATETIME NOT NULL,- "userId" TEXT,- CONSTRAINT "AgentGraphExecutionSchedule_agentGraphId_agentGraphVersion_fkey" FOREIGN KEY ("agentGraphId", "agentGraphVersion") REFERENCES "AgentGraph" ("id", "version") ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "AgentGraphExecutionSchedule_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE-);-INSERT INTO "new_AgentGraphExecutionSchedule" ("agentGraphId", "agentGraphVersion", "id", "inputData", "isEnabled", "lastUpdated", "schedule") SELECT "agentGraphId", "agentGraphVersion", "id", "inputData", "isEnabled", "lastUpdated", "schedule" FROM "AgentGraphExecutionSchedule";-DROP TABLE "AgentGraphExecutionSchedule";-ALTER TABLE "new_AgentGraphExecutionSchedule" RENAME TO "AgentGraphExecutionSchedule";-CREATE INDEX "AgentGraphExecutionSchedule_isEnabled_idx" ON "AgentGraphExecutionSchedule"("isEnabled");-PRAGMA foreign_key_check;-PRAGMA foreign_keys=ON;---- CreateIndex-CREATE UNIQUE INDEX "User_email_key" ON "User"("email");diff --git a/rnd/autogpt_server/postgres/migrations/20240805115810_add_user_management/migration.sql b/rnd/autogpt_server/migrations/20240805115810_add_user_management/migration.sqlsimilarity index 100%rename from rnd/autogpt_server/postgres/migrations/20240805115810_add_user_management/migration.sqlrename to rnd/autogpt_server/migrations/20240805115810_add_user_management/migration.sqldiff --git a/rnd/autogpt_server/migrations/20240807123716_add_index_users/migration.sql b/rnd/autogpt_server/migrations/20240807123738_add_index_users/migration.sqlsimilarity index 100%rename from rnd/autogpt_server/migrations/20240807123716_add_index_users/migration.sqlrename to rnd/autogpt_server/migrations/20240807123738_add_index_users/migration.sqldiff --git a/rnd/autogpt_server/migrations/20240808095419_add_required_user_ids/migration.sql b/rnd/autogpt_server/migrations/20240808095419_add_required_user_ids/migration.sqlindex 9d9e9442af..8d4fb9ef5c 100644--- a/rnd/autogpt_server/migrations/20240808095419_add_required_user_ids/migration.sql+++ b/rnd/autogpt_server/migrations/20240808095419_add_required_user_ids/migration.sql@@ -1,92 +1,25 @@--- RedefineTables-PRAGMA foreign_keys=OFF;+-- Update existing entries with NULL userId+UPDATE "AgentGraph" SET "userId" = '3e53486c-cf57-477e-ba2a-cb02dc828e1a' WHERE "userId" IS NULL;+UPDATE "AgentGraphExecution" SET "userId" = '3e53486c-cf57-477e-ba2a-cb02dc828e1a' WHERE "userId" IS NULL;+UPDATE "AgentGraphExecutionSchedule" SET "userId" = '3e53486c-cf57-477e-ba2a-cb02dc828e1a' WHERE "userId" IS NULL;-CREATE TABLE "new_AgentGraphExecution" (- "id" TEXT NOT NULL PRIMARY KEY,- "agentGraphId" TEXT NOT NULL,- "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,- "userId" TEXT NOT NULL,- CONSTRAINT "AgentGraphExecution_agentGraphId_agentGraphVersion_fkey"- FOREIGN KEY ("agentGraphId", "agentGraphVersion")- REFERENCES "AgentGraph" ("id", "version")- ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "AgentGraphExecution_userId_fkey"- FOREIGN KEY ("userId")- REFERENCES "User" ("id")- ON DELETE RESTRICT ON UPDATE CASCADE-);-INSERT INTO "new_AgentGraphExecution" ("agentGraphId", "agentGraphVersion", "id", "userId")-SELECT "agentGraphId",- "agentGraphVersion",- "id",- CASE WHEN "userId" IS NULL THEN '3e53486c-cf57-477e-ba2a-cb02dc828e1a' ELSE "userId" END-FROM "AgentGraphExecution";-DROP TABLE "AgentGraphExecution";-ALTER TABLE "new_AgentGraphExecution" RENAME TO "AgentGraphExecution";+-- AlterTable+ALTER TABLE "AgentGraph" ALTER COLUMN "userId" SET NOT NULL;-CREATE TABLE "new_AgentGraph" (- "id" TEXT NOT NULL,- "version" INTEGER NOT NULL DEFAULT 1,- "name" TEXT,- "description" TEXT,- "isActive" BOOLEAN NOT NULL DEFAULT true,- "isTemplate" BOOLEAN NOT NULL DEFAULT false,- "userId" TEXT NOT NULL,- "agentGraphParentId" TEXT,- PRIMARY KEY ("id", "version"),- CONSTRAINT "AgentGraph_userId_fkey"- FOREIGN KEY ("userId")- REFERENCES "User" ("id")- ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "AgentGraph_agentGraphParentId_version_fkey"- FOREIGN KEY ("agentGraphParentId", "version")- REFERENCES "AgentGraph" ("id", "version")- ON DELETE RESTRICT ON UPDATE CASCADE-);-INSERT INTO "new_AgentGraph" ("agentGraphParentId", "description", "id", "isActive", "isTemplate", "name", "userId", "version")-SELECT "agentGraphParentId",- "description",- "id",- "isActive",- "isTemplate",- "name",- CASE WHEN "userId" IS NULL THEN '3e53486c-cf57-477e-ba2a-cb02dc828e1a' ELSE "userId" END,- "version"-FROM "AgentGraph";-DROP TABLE "AgentGraph";-ALTER TABLE "new_AgentGraph" RENAME TO "AgentGraph";+-- AlterTable+ALTER TABLE "AgentGraphExecution" ALTER COLUMN "userId" SET NOT NULL;-CREATE TABLE "new_AgentGraphExecutionSchedule" (- "id" TEXT NOT NULL PRIMARY KEY,- "agentGraphId" TEXT NOT NULL,- "agentGraphVersion" INTEGER NOT NULL DEFAULT 1,- "schedule" TEXT NOT NULL,- "isEnabled" BOOLEAN NOT NULL DEFAULT true,- "inputData" TEXT NOT NULL,- "lastUpdated" DATETIME NOT NULL,- "userId" TEXT NOT NULL,- CONSTRAINT "AgentGraphExecutionSchedule_agentGraphId_agentGraphVersion_fkey"- FOREIGN KEY ("agentGraphId", "agentGraphVersion")- REFERENCES "AgentGraph" ("id", "version")- ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "AgentGraphExecutionSchedule_userId_fkey"- FOREIGN KEY ("userId")- REFERENCES "User" ("id")- ON DELETE RESTRICT ON UPDATE CASCADE-);-INSERT INTO "new_AgentGraphExecutionSchedule" ("agentGraphId", "agentGraphVersion", "id", "inputData", "isEnabled", "lastUpdated", "schedule", "userId")-SELECT "agentGraphId",- "agentGraphVersion",- "id",- "inputData",- "isEnabled",- "lastUpdated",- "schedule",- CASE WHEN "userId" IS NULL THEN '3e53486c-cf57-477e-ba2a-cb02dc828e1a' ELSE "userId" END-FROM "AgentGraphExecutionSchedule";-DROP TABLE "AgentGraphExecutionSchedule";-ALTER TABLE "new_AgentGraphExecutionSchedule" RENAME TO "AgentGraphExecutionSchedule";-CREATE INDEX "AgentGraphExecutionSchedule_isEnabled_idx" ON "AgentGraphExecutionSchedule"("isEnabled");+-- AlterTable+ALTER TABLE "AgentGraphExecutionSchedule" ALTER COLUMN "userId" SET NOT NULL;-PRAGMA foreign_key_check;-PRAGMA foreign_keys=ON;+-- AlterForeignKey+ALTER TABLE "AgentGraph" DROP CONSTRAINT "AgentGraph_userId_fkey";+ALTER TABLE "AgentGraph" ADD CONSTRAINT "AgentGraph_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;++-- AlterForeignKey+ALTER TABLE "AgentGraphExecution" DROP CONSTRAINT "AgentGraphExecution_userId_fkey";+ALTER TABLE "AgentGraphExecution" ADD CONSTRAINT "AgentGraphExecution_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;++-- AlterForeignKey+ALTER TABLE "AgentGraphExecutionSchedule" DROP CONSTRAINT "AgentGraphExecutionSchedule_userId_fkey";+ALTER TABLE "AgentGraphExecutionSchedule" ADD CONSTRAINT "AgentGraphExecutionSchedule_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;diff --git a/rnd/autogpt_server/migrations/migration_lock.toml b/rnd/autogpt_server/migrations/migration_lock.tomldeleted file mode 100644index e5e5c4705a..0000000000--- a/rnd/autogpt_server/migrations/migration_lock.toml+++ /dev/null@@ -1,3 +0,0 @@-# Please do not edit this file manually-# It should be added in your version-control system (i.e. Git)-provider = "sqlite"\ No newline at end of filediff --git a/rnd/autogpt_server/postgres/migrations/20240807123738_add_index_users/migration.sql b/rnd/autogpt_server/postgres/migrations/20240807123738_add_index_users/migration.sqldeleted file mode 100644index 54a70dca5a..0000000000--- a/rnd/autogpt_server/postgres/migrations/20240807123738_add_index_users/migration.sql+++ /dev/null@@ -1,5 +0,0 @@--- CreateIndex-CREATE INDEX "User_id_idx" ON "User"("id");---- CreateIndex-CREATE INDEX "User_email_idx" ON "User"("email");diff --git a/rnd/autogpt_server/postgres/migrations/20240808095419_add_required_user_ids/migration.sql b/rnd/autogpt_server/postgres/migrations/20240808095419_add_required_user_ids/migration.sqldeleted file mode 100644index 8d4fb9ef5c..0000000000--- a/rnd/autogpt_server/postgres/migrations/20240808095419_add_required_user_ids/migration.sql+++ /dev/null@@ -1,25 +0,0 @@--- Update existing entries with NULL userId-UPDATE "AgentGraph" SET "userId" = '3e53486c-cf57-477e-ba2a-cb02dc828e1a' WHERE "userId" IS NULL;-UPDATE "AgentGraphExecution" SET "userId" = '3e53486c-cf57-477e-ba2a-cb02dc828e1a' WHERE "userId" IS NULL;-UPDATE "AgentGraphExecutionSchedule" SET "userId" = '3e53486c-cf57-477e-ba2a-cb02dc828e1a' WHERE "userId" IS NULL;---- AlterTable-ALTER TABLE "AgentGraph" ALTER COLUMN "userId" SET NOT NULL;---- AlterTable-ALTER TABLE "AgentGraphExecution" ALTER COLUMN "userId" SET NOT NULL;---- AlterTable-ALTER TABLE "AgentGraphExecutionSchedule" ALTER COLUMN "userId" SET NOT NULL;---- AlterForeignKey-ALTER TABLE "AgentGraph" DROP CONSTRAINT "AgentGraph_userId_fkey";-ALTER TABLE "AgentGraph" ADD CONSTRAINT "AgentGraph_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;---- AlterForeignKey-ALTER TABLE "AgentGraphExecution" DROP CONSTRAINT "AgentGraphExecution_userId_fkey";-ALTER TABLE "AgentGraphExecution" ADD CONSTRAINT "AgentGraphExecution_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;---- AlterForeignKey-ALTER TABLE "AgentGraphExecutionSchedule" DROP CONSTRAINT "AgentGraphExecutionSchedule_userId_fkey";-ALTER TABLE "AgentGraphExecutionSchedule" ADD CONSTRAINT "AgentGraphExecutionSchedule_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;diff --git a/rnd/autogpt_server/postgres/migrations/20240902223343_add_stats_column/migration.sql b/rnd/autogpt_server/postgres/migrations/20240902223343_add_stats_column/migration.sqldeleted file mode 100644index f9c6be8010..0000000000--- a/rnd/autogpt_server/postgres/migrations/20240902223343_add_stats_column/migration.sql+++ /dev/null@@ -1,5 +0,0 @@--- AlterTable-ALTER TABLE "AgentGraphExecution" ADD COLUMN "stats" TEXT;---- AlterTable-ALTER TABLE "AgentNodeExecution" ADD COLUMN "stats" TEXT;diff --git a/rnd/autogpt_server/postgres/migrations/migration_lock.toml b/rnd/autogpt_server/postgres/migrations/migration_lock.tomldeleted file mode 100644index fbffa92c2b..0000000000--- a/rnd/autogpt_server/postgres/migrations/migration_lock.toml+++ /dev/null@@ -1,3 +0,0 @@-# Please do not edit this file manually-# It should be added in your version-control system (i.e. Git)-provider = "postgresql"\ No newline at end of filediff --git a/rnd/autogpt_server/postgres/schema.prisma b/rnd/autogpt_server/postgres/schema.prismadeleted file mode 100644index f06f060091..0000000000--- a/rnd/autogpt_server/postgres/schema.prisma+++ /dev/null@@ -1,195 +0,0 @@-// THIS FILE IS AUTO-GENERATED, RUN `poetry run schema` TO UPDATE-datasource db {- provider = "postgresql"- url = env("DATABASE_URL")-}--generator client {- provider = "prisma-client-py"- recursive_type_depth = 5- interface = "asyncio"-}--// User model to mirror Auth provider users-model User {- id String @id // This should match the Supabase user ID- email String @unique- name String?- createdAt DateTime @default(now())- updatedAt DateTime @updatedAt-- // Relations- AgentGraphs AgentGraph[]- AgentGraphExecutions AgentGraphExecution[]- AgentGraphExecutionSchedules AgentGraphExecutionSchedule[]-- @@index([id])- @@index([email])-}--// This model describes the Agent Graph/Flow (Multi Agent System).-model AgentGraph {- id String @default(uuid())- version Int @default(1)-- name String?- description String?- isActive Boolean @default(true)- isTemplate Boolean @default(false)-- // Link to User model- userId String- user User @relation(fields: [userId], references: [id])-- AgentNodes AgentNode[]- AgentGraphExecution AgentGraphExecution[]- AgentGraphExecutionSchedule AgentGraphExecutionSchedule[]-- // All sub-graphs are defined within this 1-level depth list (even if it's a nested graph).- AgentSubGraphs AgentGraph[] @relation("AgentSubGraph")- agentGraphParentId String?- AgentGraphParent AgentGraph? @relation("AgentSubGraph", fields: [agentGraphParentId, version], references: [id, version])-- @@id(name: "graphVersionId", [id, version])-}--// This model describes a single node in the Agent Graph/Flow (Multi Agent System).-model AgentNode {- id String @id @default(uuid())-- agentBlockId String- AgentBlock AgentBlock @relation(fields: [agentBlockId], references: [id])-- agentGraphId String- agentGraphVersion Int @default(1)- AgentGraph AgentGraph @relation(fields: [agentGraphId, agentGraphVersion], references: [id, version])-- // List of consumed input, that the parent node should provide.- Input AgentNodeLink[] @relation("AgentNodeSink")-- // List of produced output, that the child node should be executed.- Output AgentNodeLink[] @relation("AgentNodeSource")-- // JSON serialized dict[str, str] containing predefined input values.- constantInput String @default("{}")-- // JSON serialized dict[str, str] containing the node metadata.- metadata String @default("{}")-- ExecutionHistory AgentNodeExecution[]-}--// This model describes the link between two AgentNodes.-model AgentNodeLink {- id String @id @default(uuid())-- // Output of a node is connected to the source of the link.- agentNodeSourceId String- AgentNodeSource AgentNode @relation("AgentNodeSource", fields: [agentNodeSourceId], references: [id])- sourceName String-- // Input of a node is connected to the sink of the link.- agentNodeSinkId String- AgentNodeSink AgentNode @relation("AgentNodeSink", fields: [agentNodeSinkId], references: [id])- sinkName String-- // Default: the data coming from the source can only be consumed by the sink once, Static: input data will be reused.- isStatic Boolean @default(false)-}--// This model describes a component that will be executed by the AgentNode.-model AgentBlock {- id String @id @default(uuid())- name String @unique-- // We allow a block to have multiple types of input & output.- // Serialized object-typed `jsonschema` with top-level properties as input/output name.- inputSchema String- outputSchema String-- // Prisma requires explicit back-references.- ReferencedByAgentNode AgentNode[]-}--// This model describes the execution of an AgentGraph.-model AgentGraphExecution {- id String @id @default(uuid())-- agentGraphId String- agentGraphVersion Int @default(1)- AgentGraph AgentGraph @relation(fields: [agentGraphId, agentGraphVersion], references: [id, version])-- AgentNodeExecutions AgentNodeExecution[]-- // Link to User model- userId String- user User @relation(fields: [userId], references: [id])-- stats String? // JSON serialized object-}--// This model describes the execution of an AgentNode.-model AgentNodeExecution {- id String @id @default(uuid())-- agentGraphExecutionId String- AgentGraphExecution AgentGraphExecution @relation(fields: [agentGraphExecutionId], references: [id])-- agentNodeId String- AgentNode AgentNode @relation(fields: [agentNodeId], references: [id])-- Input AgentNodeExecutionInputOutput[] @relation("AgentNodeExecutionInput")- Output AgentNodeExecutionInputOutput[] @relation("AgentNodeExecutionOutput")-- // sqlite does not support enum- // enum Status { INCOMPLETE, QUEUED, RUNNING, SUCCESS, FAILED }- executionStatus String- // Final JSON serialized input data for the node execution.- executionData String?- addedTime DateTime @default(now())- queuedTime DateTime?- startedTime DateTime?- endedTime DateTime?-- stats String? // JSON serialized object-}--// This model describes the output of an AgentNodeExecution.-model AgentNodeExecutionInputOutput {- id String @id @default(uuid())-- name String- data String- time DateTime @default(now())-- // Prisma requires explicit back-references.- referencedByInputExecId String?- ReferencedByInputExec AgentNodeExecution? @relation("AgentNodeExecutionInput", fields: [referencedByInputExecId], references: [id])- referencedByOutputExecId String?- ReferencedByOutputExec AgentNodeExecution? @relation("AgentNodeExecutionOutput", fields: [referencedByOutputExecId], references: [id])-- // Input and Output pin names are unique for each AgentNodeExecution.- @@unique([referencedByInputExecId, referencedByOutputExecId, name])-}--// This model describes the recurring execution schedule of an Agent.-model AgentGraphExecutionSchedule {- id String @id-- agentGraphId String- agentGraphVersion Int @default(1)- AgentGraph AgentGraph @relation(fields: [agentGraphId, agentGraphVersion], references: [id, version])-- schedule String // cron expression- isEnabled Boolean @default(true)- inputData String // JSON serialized object-- // default and set the value on each update, lastUpdated field has no time zone.- lastUpdated DateTime @updatedAt-- // Link to User model- userId String- user User @relation(fields: [userId], references: [id])-- @@index([isEnabled])-}diff --git a/rnd/autogpt_server/pyproject.toml b/rnd/autogpt_server/pyproject.tomlindex 0ad328fd3c..3fb3ba8dd1 100644--- a/rnd/autogpt_server/pyproject.toml+++ b/rnd/autogpt_server/pyproject.toml@@ -68,9 +68,7 @@ ws = "autogpt_server.ws_app:main"cli = "autogpt_server.cli:main"format = "linter:format"lint = "linter:lint"-schema = "linter:schema"-schema_lint = "linter:schema_lint"-+test = "run_tests:test"# https://poethepoet.natn.io/index.html[tool.poe]poetry_command = ""diff --git a/rnd/autogpt_server/run_tests.py b/rnd/autogpt_server/run_tests.pynew file mode 100644index 0000000000..5c83a9f26c--- /dev/null+++ b/rnd/autogpt_server/run_tests.py@@ -0,0 +1,69 @@+import subprocess+import sys+import time+++def wait_for_postgres(max_retries=5, delay=5):+ for _ in range(max_retries):+ try:+ result = subprocess.run(+ [+ "docker-compose",+ "-f",+ "docker-compose.test.yaml",+ "exec",+ "postgres-test",+ "pg_isready",+ "-U",+ "agpt_user",+ "-d",+ "agpt_local",+ ],+ check=True,+ capture_output=True,+ text=True,+ )+ if "accepting connections" in result.stdout:+ print("PostgreSQL is ready.")+ return True+ except subprocess.CalledProcessError:+ print(f"PostgreSQL is not ready yet. Retrying in {delay} seconds...")+ time.sleep(delay)+ print("Failed to connect to PostgreSQL.")+ return False+++def run_command(command, check=True):+ try:+ subprocess.run(command, check=check)+ except subprocess.CalledProcessError as e:+ print(f"Command failed: {e}")+ sys.exit(1)+++def test():+ # Start PostgreSQL with Docker Compose+ run_command(+ [+ "docker-compose",+ "-f",+ "docker-compose.test.yaml",+ "up",+ "-d",+ "postgres-test",+ ]+ )++ if not wait_for_postgres():+ run_command(["docker-compose", "-f", "docker-compose.test.yaml", "down"])+ sys.exit(1)++ # Run Prisma migrations+ run_command(["prisma", "migrate", "dev"])++ # Run the tests+ result = subprocess.run(["pytest"] + sys.argv[1:], check=False)++ run_command(["docker-compose", "-f", "docker-compose.test.yaml", "down"])++ sys.exit(result.returncode)diff --git a/rnd/autogpt_server/schema.prisma b/rnd/autogpt_server/schema.prismaindex 6cd8ac8ad5..f06f060091 100644--- a/rnd/autogpt_server/schema.prisma+++ b/rnd/autogpt_server/schema.prisma@@ -1,6 +1,7 @@+// THIS FILE IS AUTO-GENERATED, RUN `poetry run schema` TO UPDATEdatasource db {- provider = "sqlite"- url = "file:./dev.db"+ provider = "postgresql"+ url = env("DATABASE_URL")}generator client {diff --git a/rnd/docker-compose.yml b/rnd/docker-compose.ymlindex 71ae1f2940..80c52d464a 100644--- a/rnd/docker-compose.yml+++ b/rnd/docker-compose.yml@@ -3,9 +3,9 @@ services:postgres:image: ankane/pgvector:latestenvironment:- POSTGRES_USER: agpt_user- POSTGRES_PASSWORD: pass123- POSTGRES_DB: agpt_local+ - POSTGRES_USER=agpt_user+ - POSTGRES_PASSWORD=pass123+ - POSTGRES_DB=agpt_localhealthcheck:test: pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DBinterval: 10s@@ -13,12 +13,16 @@ services:retries: 5ports:- "5432:5432"+ networks:+ - app-networkredis:image: redis:latestcommand: redis-server --requirepass passwordports:- "6379:6379"+ networks:+ - app-networkrest_server:build:@@ -40,6 +44,8 @@ services:- AUTH_ENABLED=falseports:- "8000:8000"+ networks:+ - app-networkws_server:build:@@ -61,3 +67,9 @@ services:- AUTH_ENABLED=falseports:- "8001:8001"+ networks:+ - app-network++networks:+ app-network:+ driver: bridge