Skip to content

Commit 5fe4f91

Browse files
committed
Add script to bootstrap SQLite & Mongo from files
Signed-off-by: Allen Rose <RoseAllenM@gmail.com>
1 parent 175db69 commit 5fe4f91

12 files changed

Lines changed: 1461 additions & 22 deletions

File tree

QUICKSTART.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cp example.docker-compose.local.vexa.yml docker-compose.local.vexa.yml
2929

3030
Edit `docker-compose.local.yml` with your credentials.
3131

32-
**Production tracking (ShotGrid):** To run without a ShotGrid seat, set **`PRODTRACK_PROVIDER=mock`** in `docker-compose.local.yml`. The mock provider uses read-only SQLite with pre-seeded data. To use real ShotGrid, set `PRODTRACK_PROVIDER=shotgrid` (or leave it unset) and add `SHOTGRID_URL`, `SHOTGRID_SCRIPT_NAME`, and `SHOTGRID_API_KEY`. See [Mock setup](#mock-production-tracking-setup) below for how to refresh or customize the mock data.
32+
**Production tracking (ShotGrid):** To run without a ShotGrid seat, set **`PRODTRACK_PROVIDER=mock`** in `docker-compose.local.yml`. Set **`MOCK_PRODTRACK_DB_PATH=src/dna/prodtrack_providers/mock_data/mock.db`** to make the active mock DB explicit and easy to change later. The mock provider uses read-only SQLite with pre-seeded data. To use real ShotGrid, set `PRODTRACK_PROVIDER=shotgrid` (or leave it unset) and add `SHOTGRID_URL`, `SHOTGRID_SCRIPT_NAME`, and `SHOTGRID_API_KEY`. See [Mock setup](#mock-production-tracking-setup) below for how to refresh or customize the mock data.
3333

3434
**LLM provider:** Set `LLM_PROVIDER` to choose which backend LLM integration to use.
3535

@@ -140,6 +140,7 @@ The React app will be available at `http://localhost:5173`.
140140
| `SHOTGRID_API_KEY` | Yes\* | - | ShotGrid API key (required when using ShotGrid) |
141141
| `SHOTGRID_SCRIPT_NAME` | Yes\* | - | ShotGrid script name (required when using ShotGrid) |
142142
| `PRODTRACK_PROVIDER` | No | `shotgrid` | `shotgrid` or `mock`; set to `mock` to use the read-only mock DB without ShotGrid |
143+
| `MOCK_PRODTRACK_DB_PATH` | No | bundled `mock.db` | Path to the SQLite DB used when `PRODTRACK_PROVIDER=mock` |
143144
| `MONGODB_URL` | No | `mongodb://mongo:27017` | MongoDB connection string |
144145
| `STORAGE_PROVIDER` | No | `mongodb` | Storage provider type |
145146
| `VEXA_API_KEY` | Yes | - | API key for Vexa transcription service |
@@ -257,12 +258,13 @@ The DNA API serves as the central hub:
257258

258259
## Mock Production Tracking Setup
259260

260-
When you set **`PRODTRACK_PROVIDER=mock`**, the backend uses a read-only mock provider backed by SQLite (`backend/src/dna/prodtrack_providers/mock_data/mock.db`). The app runs normally with this data so you can develop and test the UI without a ShotGrid seat.
261+
When you set **`PRODTRACK_PROVIDER=mock`**, the backend uses a read-only mock provider backed by SQLite. By default, set **`MOCK_PRODTRACK_DB_PATH=src/dna/prodtrack_providers/mock_data/mock.db`** in `docker-compose.local.yml` so the active DB is explicit and easy to change. The app runs normally with this data so you can develop and test the UI without a ShotGrid seat.
261262

262263
### Using the mock provider
263264

264-
- In `docker-compose.local.yml`, set **`PRODTRACK_PROVIDER=mock`**. You do not need to set any ShotGrid variables when using the mock.
265+
- In `docker-compose.local.yml`, set **`PRODTRACK_PROVIDER=mock`** and **`MOCK_PRODTRACK_DB_PATH=src/dna/prodtrack_providers/mock_data/mock.db`**.
265266
- The mock provider is used only when explicitly set; there is no automatic fallback if ShotGrid credentials are missing.
267+
- To switch the backend to a bootstrapped local DB, change `MOCK_PRODTRACK_DB_PATH` to `/app/.local/mock.db`.
266268

267269
### Refreshing or customizing mock data from ShotGrid
268270

@@ -283,10 +285,34 @@ docker-compose -f docker-compose.yml -f docker-compose.local.yml run --rm api \
283285
--api-key 'YOUR_API_KEY'
284286
```
285287

286-
- This overwrites `mock_data/mock.db` with entities (projects, users, shots, assets, tasks, versions, playlists, notes) from the given ShotGrid project.
288+
- To bootstrap sample review data, first start Mongo, then run `bootstrap_dataset`.
289+
- By default, `bootstrap_dataset` writes to `backend/.local/mock.db`, so it does not modify the checked-in mock DB.
290+
- If you want the backend to use that bootstrapped DB, set `MOCK_PRODTRACK_DB_PATH=/app/.local/mock.db` in `docker-compose.local.yml`.
291+
- `seed-mock-db` overwrites `mock_data/mock.db` with entities (projects, users, shots, assets, tasks, versions, playlists, notes) from the given ShotGrid project.
287292
- Use `--skip-thumbnails` to skip downloading version thumbnails (faster seed; thumbnails will not work after signed URLs expire).
288293
- Without `--skip-thumbnails`, thumbnails are downloaded to `mock_data/thumbnails/` and served by the API at `/api/mock-thumbnails/{version_id}` so they keep working after ShotGrid signed URLs expire.
289294

295+
Example sample bootstrap workflow:
296+
297+
```bash
298+
cd backend
299+
300+
# Start only Mongo first
301+
make start-mongo
302+
303+
# See available arguments
304+
python -m dna.devtools.bootstrap_dataset --help
305+
306+
# Preview the import without writing anything
307+
python -m dna.devtools.bootstrap_dataset ../sample_dailies_dataset --dry-run
308+
309+
# Seed SQLite + Mongo using the default local SQLite output
310+
python -m dna.devtools.bootstrap_dataset ../sample_dailies_dataset
311+
312+
# Then start the full backend stack so the API comes up with the seeded data
313+
make start-local
314+
```
315+
290316
The mock provider is **read-only**: it does not write to ShotGrid or to the SQLite file at runtime. Writes such as publishing notes will raise an error when using the mock provider.
291317

292318
## Docker Compose Files

backend/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ backend/docker-compose.vexa.yml
4242
# Local environment files
4343
docker-compose.local.yml
4444
docker-compose.local.vexa.yml
45+
.local/

backend/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ services:
2929
- ./pytest.ini:/app/pytest.ini
3030
- ./.coveragerc:/app/.coveragerc
3131
- ./htmlcov:/app/htmlcov
32+
- ./.local:/app/.local
3233
environment:
3334
- PYTHONUNBUFFERED=1
3435
- SHOTGRID_URL=https://your-shotgrid-url.com

backend/example.docker-compose.local.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Local development override. Copy to docker-compose.local.yml and fill in secrets.
22
# Auth: AUTH_PROVIDER=none uses the noop provider (sign in with any email; no token validation).
33
# Prodtrack: Set PRODTRACK_PROVIDER=mock to use the read-only mock (no ShotGrid needed).
4+
# Mock DB path: change MOCK_PRODTRACK_DB_PATH to /app/.local/mock.db if you
5+
# want the backend to use a locally bootstrapped DB instead of the checked-in fixture.
46
# To use real ShotGrid, set PRODTRACK_PROVIDER=shotgrid and SHOTGRID_URL, SHOTGRID_SCRIPT_NAME, SHOTGRID_API_KEY.
57
services:
68
api:
@@ -10,6 +12,7 @@ services:
1012
- SHOTGRID_API_KEY=************
1113
- SHOTGRID_SCRIPT_NAME=DNA_local_testing
1214
- PRODTRACK_PROVIDER=mock
15+
- MOCK_PRODTRACK_DB_PATH=src/dna/prodtrack_providers/mock_data/mock.db
1316
- VEXA_API_KEY=**********
1417
- VEXA_API_URL=http://vexa:8056
1518
- OPENAI_API_KEY=your-openai-api-key

backend/makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ format-python: venv-lint
4444
.venv-lint/bin/isort src/ tests/
4545

4646
seed-mock-db:
47-
$(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.local.yml run --rm api python -m dna.prodtrack_providers.mock_data.seed_db --project-id 124 --url https://aswf.shotgrid.autodesk.com --script-name DNA_local_testing --api-key '$(SHOTGRID_API_KEY)'
47+
$(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.local.yml run --rm api python -m dna.prodtrack_providers.mock_data.seed_db --project-id 124 --url https://aswf.shotgrid.autodesk.com --script-name DNA_local_testing --api-key '$(SHOTGRID_API_KEY)'
48+
49+
start-mongo:
50+
$(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.local.yml up -d mongo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Developer tooling utilities for backend workflows."""

0 commit comments

Comments
 (0)