Skip to content

Commit 56e74ed

Browse files
Adds environment variables for burr settings (#525)
See #523 -- this allows us to more flexible define configuration for the tortoise ORM, so it is not dependent on your location with regards to the git repo.
1 parent 650623b commit 56e74ed

File tree

3 files changed

+22
-85
lines changed

3 files changed

+22
-85
lines changed

burr/tracking/server/s3/README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,22 @@ We will be addressing the limitations above. Particularly:
143143

144144
Scratchpad/notes:
145145

146-
To reset, do:
146+
To iterate, first set your environment variables:
147+
147148
```bash
148-
rm -rf ~/.burr_server &&
149-
mkdir ~/.burr_server &&
150-
rm -rf ./burr/tracking/server/s3/migrations &&
151-
aerich init -t burr.tracking.server.s3.settings.TORTOISE_ORM --location ./burr/tracking/server/s3/migrations &&
152-
aerich init-db &&
153-
AWS_PROFILE=dagworks burr --no-open
149+
export BURR_SERVER_ROOT=... # the root of your burr server
150+
export BURR_DB_FILENAME=db.sqlite3 # default, use if you want another
151+
export AWS_PROFILE=... # or configure another way
154152
```
155153

156-
Explanation:
154+
Then to reset everything, run:
155+
```bash
156+
rm -rf "$BURR_SERVER_ROOT" # clear everything, including migrations
157+
mkdir "$BURR_SERVER_ROOT" # create the directory
158+
aerich init -t burr.tracking.server.s3.settings.TORTOISE_ORM --location "$BURR_SERVER_ROOT"/migrations # create the migrations directory if needed
159+
cd "$BURR_SERVER_ROOT" # change to the directory
160+
aerich init-db # initialize
161+
burr --no-open --backend s3 # should use all the other env variables you set
162+
```
157163

158-
- `rm -rf ~/.burr_server` (will be turned to an env variable)
159-
- `mkdir ~/.burr_server` (ditto)
160-
- (from git root) `rm -rf ./burr/tracking/server/s3/migrations`
161-
- (from git root) `aerich init -t burr.tracking.server.s3.settings.TORTOISE_ORM --location ./burr/tracking/server/s3/migrations`
162-
- (from git root) `aerich init-db`
164+
Note you obviously do not need to fully reset if you're not developing from scratch.

burr/tracking/server/s3/migrations/models/0_20240730151503_init.py

-70
This file was deleted.

burr/tracking/server/s3/settings.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
from pathlib import Path
1+
import os
22

3-
DB_PATH = Path("~/.burr_server/db.sqlite3").expanduser()
3+
BURR_SERVER_ROOT = os.environ.get("BURR_SERVER_ROOT", os.path.expanduser("~/.burr_server"))
4+
BURR_DB_FILENAME = os.environ.get("BURR_DB_FILENAME", "db.sqlite3")
45

6+
DB_PATH = os.path.join(
7+
BURR_SERVER_ROOT,
8+
BURR_DB_FILENAME,
9+
)
510
TORTOISE_ORM = {
611
"connections": {"default": f"sqlite:///{DB_PATH}"},
712
"apps": {

0 commit comments

Comments
 (0)