Skip to content

Commit 388e241

Browse files
authored
Merge pull request #1239 from CodeForPhilly/staging
PR from staging to main
2 parents e92b9f1 + db76fd3 commit 388e241

File tree

158 files changed

+6118
-10000
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+6118
-10000
lines changed

.github/workflows/pr_checks_backend.yml

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ on:
66
- staging
77
paths:
88
- 'data/**'
9-
- 'Dockerfile-pg'
10-
- 'init_pg.sql'
119
- 'docker compose.yml'
1210
workflow_dispatch:
1311

@@ -24,53 +22,17 @@ jobs:
2422
- name: Set up Docker Compose
2523
uses: docker/setup-qemu-action@v3
2624

27-
- name: Set up Python
28-
uses: actions/setup-python@v5
29-
with:
30-
python-version: '3.11.4'
31-
3225
test:
3326
runs-on: ubuntu-latest
3427
needs: setup
35-
defaults:
36-
run:
37-
working-directory: data/src
38-
env:
39-
VACANT_LOTS_DB: 'postgresql://postgres:temp-CI-only@localhost:5433/vacantlotdb'
40-
services:
41-
postgres:
42-
image: postgis/postgis:16-3.4
43-
env:
44-
POSTGRES_USER: postgres
45-
POSTGRES_PASSWORD: temp-CI-only # CI-only, safe to hardcode for temporary container
46-
POSTGRES_DB: vacantlotdb
47-
ports:
48-
- 5433:5432
49-
# Set health checks to wait until postgres is ready
50-
options: >-
51-
--health-cmd pg_isready
52-
--health-interval 10s
53-
--health-timeout 5s
54-
--health-retries 5
5528
steps:
5629
- name: Checkout repository
5730
uses: actions/checkout@v4
5831

59-
- name: Set up Python
60-
uses: actions/setup-python@v5
61-
with:
62-
python-version: '3.11.4'
63-
64-
- name: Install and configure pipenv
65-
run: |
66-
python -m pip install --upgrade pip
67-
pip install pipenv
68-
echo "Using Python: $(which python)"
69-
pipenv --python $(which python) install --dev
70-
7132
- name: Run Pytest
72-
working-directory: data/src
73-
run: PYTHONPATH=$PYTHONPATH:. pipenv run pytest
33+
run: |
34+
cd data
35+
docker compose run --rm vacant-lots-proj sh -c "pytest"
7436
7537
run-formatter:
7638
runs-on: ubuntu-latest
@@ -84,7 +46,7 @@ jobs:
8446
- name: Run Ruff Formatter in Docker
8547
run: |
8648
cd data
87-
docker compose run --rm formatter sh -c "pip install ruff && ruff format --check --exclude '/usr/src/app/awkde/'"
49+
docker compose run --rm vacant-lots-proj sh -c "ruff format --check"
8850
8951
run-linter:
9052
runs-on: ubuntu-latest
@@ -98,7 +60,7 @@ jobs:
9860
- name: Run Ruff Linter in Docker
9961
run: |
10062
cd data
101-
docker compose run --rm linter
63+
docker compose run --rm vacant-lots-proj sh -c "ruff check"
10264
10365
build-project:
10466
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
run: npm ci
2626

2727
- name: Create Tag
28-
uses: cycjimmy/[email protected].0
28+
uses: cycjimmy/[email protected].1
2929
env:
3030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3131

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ data/src/app/service-account-key.json
6060
# compiled python files
6161
*.pyc
6262

63-
tmp/
64-
6563
# Local python development files
6664
.python-version
65+
66+
# Cached and temporary data files from pipeline
67+
storage/

.pre-commit-config.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ repos:
1818
types_or: [python, pyi, jupyter]
1919
files: \.py$
2020

21-
# Dependency checks for Python
22-
- id: check-python-dependencies
23-
name: Check Python dependencies
24-
entry: bash -c 'cd data/src && pipenv check --bare --quiet || (echo "Python dependencies check failed" && exit 1)'
25-
language: system
26-
files: ^data/src/Pipfile$
27-
2821
# Radon MI and Halstead checks
2922
- id: radon-check
3023
name: Radon Maintainability and Halstead Checks

data/Dockerfile

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
1-
# Use an official Python 3.11 runtime as a parent image
2-
FROM python:3.11.4
1+
FROM python:3.11.4 AS tippecanoe
2+
RUN apt-get update && apt-get -y install \
3+
make \
4+
gcc \
5+
g++ \
6+
libsqlite3-dev \
7+
zlib1g-dev
8+
# TODO: Pin Tippecanoe to a specific version
9+
RUN curl -L https://github.com/felt/tippecanoe/tarball/master -o tippecanoe.tar.gz \
10+
&& mkdir tippecanoe && tar -xzf tippecanoe.tar.gz -C tippecanoe --strip-components=1 \
11+
&& tar -xzf tippecanoe.tar.gz \
12+
&& cd tippecanoe \
13+
&& make \
14+
&& make install
15+
16+
FROM python:3.11.4 AS dependencies
17+
RUN curl -LsSf https://astral.sh/uv/0.7.12/install.sh | sh
18+
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=0 PATH="/root/.local/bin/:$PATH"
19+
WORKDIR /app
20+
COPY uv.lock pyproject.toml ./
21+
#TODO: in the future, remove development dependencies from final container
22+
RUN uv sync --locked
23+
324

4-
# Set the working directory in the container
5-
WORKDIR /usr/src/app
25+
FROM python:3.11.4
626

727
# Install system dependencies for GDAL and Tippecanoe
28+
# TODO: Figure out which Tippecanoe dependencies we can remove since we've moved this to a
29+
# separate stage
830
RUN apt-get update && apt-get install -y \
931
libgdal-dev \
1032
gcc \
@@ -15,38 +37,17 @@ RUN apt-get update && apt-get install -y \
1537
lsb-release \
1638
&& rm -rf /var/lib/apt/lists/*
1739

18-
# install postgres client 16 for psql and pg_dump executables for backups.
19-
# should match the version used in the other docker file for the postgres install
20-
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
21-
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
22-
RUN apt update
23-
RUN apt install -y postgresql-client-16
24-
25-
# Set GDAL environment variables
26-
ENV GDAL_VERSION=3.6.2
27-
ENV GDAL_CONFIG=/usr/bin/gdal-config
28-
29-
# Install Pipenv
30-
RUN pip install pipenv
31-
32-
# Copy the Pipfile and Pipfile.lock from the src directory
33-
COPY src/Pipfile src/Pipfile.lock ./
40+
COPY --from=tippecanoe /usr/local/bin/tippecanoe /usr/local/bin/tippecanoe
41+
COPY --from=dependencies /app /app
3442

35-
# update pipfile
36-
RUN pipenv lock
43+
ENV GDAL_VERSION=3.6.2 \
44+
GDAL_CONFIG=/usr/bin/gdal-config \
45+
# place .venv binaries copied from dependencies stage to front of PATH.
46+
# This includes python, pip, and individual package binaries
47+
PATH="/app/.venv/bin:$PATH"
3748

38-
# Install the dependencies from Pipfile
39-
RUN pipenv install --deploy --ignore-pipfile
40-
41-
# Clone and build Tippecanoe
42-
RUN git clone https://github.com/felt/tippecanoe.git \
43-
&& cd tippecanoe \
44-
&& make \
45-
&& make install
49+
WORKDIR /app
50+
COPY src ./src
4651

47-
# Copy the src directory
48-
COPY src/ .
4952

50-
# Use Pipenv to run the script
51-
# Adjust the path to your main Python script if needed
52-
CMD ["pipenv", "run", "python", "./script.py"]
53+
CMD ["python", "-m", "src.main"]

data/Dockerfile-pg

Lines changed: 0 additions & 26 deletions
This file was deleted.

data/Dockerfile-timescale

Lines changed: 0 additions & 26 deletions
This file was deleted.

data/docker-compose.yml

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,94 +6,16 @@ services:
66
image: vacant-lots-proj:latest
77
environment:
88
- GOOGLE_APPLICATION_CREDENTIALS=/app/service-account-key.json
9-
- VACANT_LOTS_DB
10-
- POSTGRES_PASSWORD
11-
- POSTGRES_PORT=5434
129
- CLEAN_GREEN_GOOGLE_KEY
1310
- PYTHONUNBUFFERED=1
1411
- GOOGLE_CLOUD_BUCKET_NAME
1512
- GOOGLE_CLOUD_PROJECT
1613
- CAGP_SLACK_API_TOKEN
1714
volumes:
18-
- ./src:/usr/src/app
15+
- ./src:/app/src
1916
- ~/.config/gcloud/application_default_credentials.json:/app/service-account-key.json
2017
- /etc/timezone:/etc/timezone:ro
2118
- /etc/localtime:/etc/localtime:ro
2219
extra_hosts:
2320
- host.docker.internal:host-gateway
2421
network_mode: 'host'
25-
26-
formatter:
27-
build:
28-
context: .
29-
volumes:
30-
- ./src:/usr/src/app
31-
command: sh -c "pip install ruff && ruff format"
32-
network_mode: 'host'
33-
34-
linter:
35-
build:
36-
context: .
37-
volumes:
38-
- ./src:/usr/src/app
39-
command: sh -c "pip install ruff && ruff check --fix"
40-
network_mode: 'host'
41-
42-
streetview:
43-
build:
44-
context: .
45-
environment:
46-
- GOOGLE_APPLICATION_CREDENTIALS=/app/service-account-key.json
47-
- CLEAN_GREEN_GOOGLE_KEY
48-
- VACANT_LOTS_DB
49-
- GOOGLE_CLOUD_BUCKET_NAME
50-
volumes:
51-
- ./src:/usr/src/app
52-
- ~/.config/gcloud/application_default_credentials.json:/app/service-account-key.json
53-
- /etc/timezone:/etc/timezone:ro
54-
- /etc/localtime:/etc/localtime:ro
55-
command: sh -c "pipenv run python streetview.py"
56-
extra_hosts:
57-
- host.docker.internal:host-gateway
58-
network_mode: 'host'
59-
60-
postgres:
61-
container_name: cagp-postgres
62-
build:
63-
context: .
64-
dockerfile: Dockerfile-pg
65-
environment:
66-
PGPORT: 5433
67-
POSTGRES_PASSWORD:
68-
restart: always
69-
ports:
70-
- '5433:5433'
71-
volumes:
72-
- database_volume:/var/lib/postgresql/data
73-
- ./init_pg.sql:/docker-entrypoint-initdb.d/init_pg.sql
74-
- /etc/timezone:/etc/timezone:ro
75-
- /etc/localtime:/etc/localtime:ro
76-
extra_hosts:
77-
- host.docker.internal:host-gateway
78-
79-
postgres-timescale:
80-
container_name: cagp-postgres-timescale
81-
build:
82-
context: .
83-
dockerfile: Dockerfile-timescale
84-
environment:
85-
PGPORT: 5434
86-
POSTGRES_PASSWORD:
87-
restart: always
88-
ports:
89-
- '5434:5434'
90-
volumes:
91-
- timescale_database_volume:/var/lib/postgresql/data
92-
- ./init_pg_timescale.sql:/docker-entrypoint-initdb.d/init_pg.sql
93-
- /etc/timezone:/etc/timezone:ro
94-
- /etc/localtime:/etc/localtime:ro
95-
extra_hosts:
96-
- host.docker.internal:host-gateway
97-
volumes:
98-
database_volume:
99-
timescale_database_volume:

data/init_pg.sql

Lines changed: 0 additions & 3 deletions
This file was deleted.

data/init_pg_timescale.sql

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)