Skip to content

Commit 3bb76ac

Browse files
jspada200Copilot
andauthored
Add Backend abstraction around SG (#37)
Building out a shotgrid providor and the abstractions needed. A providor for SG was added and pydantic models for different entitiy types. You can test the API by connecting the the AWSF site Sam setup by copying sg_example.docker-compose.local.yml, renaming to docker-compose.local.yml and updating the variables. Once you update you can run make build and make start-local. Once up, you can test out the API with http://0.0.0.0:8000/docs --------- Signed-off-by: James Spadafora <spadjv@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 047586f commit 3bb76ac

23 files changed

+2001
-23
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: always-update-tests
3+
description: Always run tests when making changes to the code.
4+
globs:
5+
alwaysApply: true
6+
---
7+
8+
# Overview
9+
10+
Always run tests when making changes to the code. For the Frontend, use npm run test. For the Backend, use make test.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: apply-comments-only-when-needed
3+
description: Only apply comments when needed.
4+
globs:
5+
alwaysApply: true
6+
---
7+
8+
# Overview
9+
10+
Only apply comments when needed. Do not apply comments to the code unless it is absolutely necessary to communicate the intent of the code. Do not apply comments to describe changes you made to the code based on the prompt.

.cursor/rules/run-formatting.mdc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: run-formatting
3+
description: Run formatting when making changes to the code.
4+
globs:
5+
alwaysApply: true
6+
---
7+
8+
# Overview
9+
10+
When making changes to the backend, run `make format-python` to format the code after you are done making changes as a final step.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Backend Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
paths:
7+
- 'backend/**'
8+
pull_request:
9+
branches: [ main, develop ]
10+
paths:
11+
- 'backend/**'
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.11'
25+
26+
- name: Install dependencies
27+
run: |
28+
pip install -r requirements.txt
29+
working-directory: backend
30+
31+
- name: Run tests with coverage
32+
run: |
33+
python -m pytest --cov-fail-under=90
34+
working-directory: backend
35+
env:
36+
SHOTGRID_URL: https://mock-shotgrid.example.com
37+
SHOTGRID_SCRIPT_NAME: mock_script
38+
SHOTGRID_API_KEY: mock_api_key

backend/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ coverage.xml
3535
dmypy.json
3636
*.log
3737
.DS_Store
38+
39+
# Local environment files
40+
docker-compose.local.yml

backend/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ RUN pip install --no-cache-dir -r requirements.txt
1717
# Copy application code
1818
COPY src/ ./src/
1919

20+
# Add src to Python path so 'dna' package is importable
21+
ENV PYTHONPATH="/app/src:${PYTHONPATH}"
22+
2023
# Expose port
2124
EXPOSE 8000
2225

backend/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ To setup the backend, you need to have the following:
4040
- An LLM provider (OpenAI, Anthropic, Google, etc.)
4141
- A transcription provider (Vexa, etc.)
4242

43+
### ShotGrid Configuration
44+
45+
To configure ShotGrid credentials, create a local docker-compose override file:
46+
47+
1. Copy the example file:
48+
```bash
49+
cp sg_example.docker-compose.local.yml docker-compose.local.yml
50+
```
51+
52+
2. Edit `docker-compose.local.yml` and update the environment variables with your ShotGrid credentials:
53+
- `SHOTGRID_URL`: Your ShotGrid site URL (e.g., `https://your-studio.shotgrid.autodesk.com`)
54+
- `SHOTGRID_API_KEY`: Your ShotGrid API key
55+
- `SHOTGRID_SCRIPT_NAME`: Your ShotGrid script name
56+
57+
3. The `docker-compose.local.yml` file is gitignored, so your credentials will not be committed to the repository.
58+
4359
### Running the Backend
4460

4561
To run the backend, you need to have the following:

backend/docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ services:
1414
- ./coverage.xml:/app/coverage.xml
1515
environment:
1616
- PYTHONUNBUFFERED=1
17+
- SHOTGRID_URL=https://your-shotgrid-url.com
18+
- SHOTGRID_API_KEY=your-shotgrid-api-key
19+
- SHOTGRID_SCRIPT_NAME=your-shotgrid-script-name
20+
- PRODTRACK_PROVIDER=shotgrid
1721
restart: unless-stopped
1822
healthcheck:
1923
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]

backend/makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
build:
2-
docker-compose build --no-cache
2+
docker-compose -f docker-compose.yml -f docker-compose.local.yml build --no-cache
33

44
start-local:
5-
docker-compose up --build
5+
docker-compose -f docker-compose.yml -f docker-compose.local.yml up --build
66

77
stop-local:
8-
docker-compose down
8+
docker-compose -f docker-compose.yml -f docker-compose.local.yml down
99

1010
logs-local:
11-
docker-compose logs -f
11+
docker-compose -f docker-compose.yml -f docker-compose.local.yml logs -f
1212

1313
restart-local:
1414
make stop-local
1515
make start-local
1616

1717
shell:
18-
docker-compose run --rm api bash
18+
docker-compose -f docker-compose.yml -f docker-compose.local.yml run --rm api bash
1919

2020
test:
21-
docker-compose run --rm api python -m pytest
21+
docker-compose -f docker-compose.yml -f docker-compose.local.yml run --rm api python -m pytest
2222

2323
test-cov:
24-
docker-compose run --rm api python -m pytest
24+
docker-compose -f docker-compose.yml -f docker-compose.local.yml run --rm api python -m pytest
2525

2626
test-cov-html:
27-
docker-compose run --rm api python -m pytest
27+
docker-compose -f docker-compose.yml -f docker-compose.local.yml run --rm api python -m pytest
2828
@echo "Coverage report available at htmlcov/index.html"
2929

3030
venv-lint:

backend/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.isort]
22
profile = "black"
3-
src_paths = ["src", "tests"]
4-
known_first_party = ["src", "dna"]
3+
src_paths = ["dna", "tests"]
4+
known_first_party = ["dna"]
55

66
[tool.black]
77
line-length = 88

0 commit comments

Comments
 (0)