Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.
Python aiburrchatbot-frameworkdagsgenerative-aigraphshacktoberfestllmopsllmsmlopspersistent-data-structurestate-machinestate-managementvisibility
Adds environment variables for burr settings (#525)
Elijah ben Izzy56e74edd4c92
diff --git a/burr/tracking/server/s3/README.md b/burr/tracking/server/s3/README.mdindex e5859b0b..acc955dc 100644--- a/burr/tracking/server/s3/README.md+++ b/burr/tracking/server/s3/README.md@@ -143,20 +143,22 @@ We will be addressing the limitations above. Particularly:Scratchpad/notes:-To reset, do:+To iterate, first set your environment variables:+```bash-rm -rf ~/.burr_server &&-mkdir ~/.burr_server &&-rm -rf ./burr/tracking/server/s3/migrations &&-aerich init -t burr.tracking.server.s3.settings.TORTOISE_ORM --location ./burr/tracking/server/s3/migrations &&-aerich init-db &&-AWS_PROFILE=dagworks burr --no-open+export BURR_SERVER_ROOT=... # the root of your burr server+export BURR_DB_FILENAME=db.sqlite3 # default, use if you want another+export AWS_PROFILE=... # or configure another way```-Explanation:+Then to reset everything, run:+```bash+rm -rf "$BURR_SERVER_ROOT" # clear everything, including migrations+mkdir "$BURR_SERVER_ROOT" # create the directory+aerich init -t burr.tracking.server.s3.settings.TORTOISE_ORM --location "$BURR_SERVER_ROOT"/migrations # create the migrations directory if needed+cd "$BURR_SERVER_ROOT" # change to the directory+aerich init-db # initialize+burr --no-open --backend s3 # should use all the other env variables you set+```-- `rm -rf ~/.burr_server` (will be turned to an env variable)-- `mkdir ~/.burr_server` (ditto)-- (from git root) `rm -rf ./burr/tracking/server/s3/migrations`-- (from git root) `aerich init -t burr.tracking.server.s3.settings.TORTOISE_ORM --location ./burr/tracking/server/s3/migrations`-- (from git root) `aerich init-db`+Note you obviously do not need to fully reset if you're not developing from scratch.diff --git a/burr/tracking/server/s3/migrations/models/0_20240730151503_init.py b/burr/tracking/server/s3/migrations/models/0_20240730151503_init.pydeleted file mode 100644index b6461010..00000000--- a/burr/tracking/server/s3/migrations/models/0_20240730151503_init.py+++ /dev/null@@ -1,70 +0,0 @@-from tortoise import BaseDBAsyncClient---async def upgrade(db: BaseDBAsyncClient) -> str:- return """- CREATE TABLE IF NOT EXISTS "project" (- "created_at" TIMESTAMP NOT NULL,- "indexed_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,- "updated_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,- "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,- "name" VARCHAR(255) NOT NULL UNIQUE,- "uri" VARCHAR(255)-) /* Static model representing a project */;-CREATE INDEX IF NOT EXISTS "idx_project_name_4d952a" ON "project" ("name");-CREATE TABLE IF NOT EXISTS "application" (- "created_at" TIMESTAMP NOT NULL,- "indexed_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,- "updated_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,- "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,- "name" VARCHAR(255) NOT NULL,- "partition_key" VARCHAR(255) NOT NULL,- "graph_file_pointer" VARCHAR(255),- "metadata_file_pointer" VARCHAR(255),- "fork_parent_id" INT REFERENCES "application" ("id") ON DELETE CASCADE,- "project_id" INT NOT NULL REFERENCES "project" ("id") ON DELETE CASCADE,- "spawning_parent_id" INT REFERENCES "application" ("id") ON DELETE CASCADE,- CONSTRAINT "uid_application_name_488894" UNIQUE ("name", "partition_key")-);-CREATE INDEX IF NOT EXISTS "idx_application_name_18706d" ON "application" ("name");-CREATE INDEX IF NOT EXISTS "idx_application_partiti_d302c8" ON "application" ("partition_key");-CREATE INDEX IF NOT EXISTS "idx_application_project_13a4e1" ON "application" ("project_id");-CREATE TABLE IF NOT EXISTS "indexstatus" (- "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,- "s3_highwatermark" VARCHAR(1023) NOT NULL,- "captured_time" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,- "project_id" INT NOT NULL REFERENCES "project" ("id") ON DELETE CASCADE-) /* Status to index. These are per-project and the latest is chosen */;-CREATE INDEX IF NOT EXISTS "idx_indexstatus_capture_d2163c" ON "indexstatus" ("captured_time");-CREATE INDEX IF NOT EXISTS "idx_indexstatus_project_52e6eb" ON "indexstatus" ("project_id");-CREATE TABLE IF NOT EXISTS "indexingjob" (- "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,- "start_time" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,- "records_processed" INT NOT NULL,- "end_time" TIMESTAMP,- "status" VARCHAR(7) NOT NULL /* SUCCESS: SUCCESS\nFAILURE: FAILURE\nRUNNING: RUNNING */,- "index_status_id" INT REFERENCES "indexstatus" ("id") ON DELETE CASCADE-) /* Job for indexing data in s3. Records only if there's something to index */;-CREATE TABLE IF NOT EXISTS "logfile" (- "created_at" TIMESTAMP NOT NULL,- "indexed_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,- "updated_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,- "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,- "s3_path" VARCHAR(1024) NOT NULL,- "tracker_id" VARCHAR(255) NOT NULL,- "min_sequence_id" INT NOT NULL,- "max_sequence_id" INT NOT NULL,- "application_id" INT NOT NULL REFERENCES "application" ("id") ON DELETE CASCADE-);-CREATE INDEX IF NOT EXISTS "idx_logfile_applica_9633be" ON "logfile" ("application_id");-CREATE TABLE IF NOT EXISTS "aerich" (- "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,- "version" VARCHAR(255) NOT NULL,- "app" VARCHAR(100) NOT NULL,- "content" JSON NOT NULL-);"""---async def downgrade(db: BaseDBAsyncClient) -> str:- return """- """diff --git a/burr/tracking/server/s3/settings.py b/burr/tracking/server/s3/settings.pyindex fe172ed9..efbc13b5 100644--- a/burr/tracking/server/s3/settings.py+++ b/burr/tracking/server/s3/settings.py@@ -1,7 +1,12 @@-from pathlib import Path+import os-DB_PATH = Path("~/.burr_server/db.sqlite3").expanduser()+BURR_SERVER_ROOT = os.environ.get("BURR_SERVER_ROOT", os.path.expanduser("~/.burr_server"))+BURR_DB_FILENAME = os.environ.get("BURR_DB_FILENAME", "db.sqlite3")+DB_PATH = os.path.join(+ BURR_SERVER_ROOT,+ BURR_DB_FILENAME,+)TORTOISE_ORM = {"connections": {"default": f"sqlite:///{DB_PATH}"},"apps": {