Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions CONTRIB.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,14 @@ flask db downgrade
```

## Using a Virtual Environment
One way to avoid hitting version incompatibility errors when running `flask` commands is to use a virtualenv. See [Python Packaging user guidelines](https://packaging.python.org/guides/installing-using-pip-and-virtualenv/) for instructions on installing virtualenv. After installing virtualenv, you can create a virtual environment by navigating to the OpenOversight directory and running the below
One way to avoid hitting version incompatibility errors when running `flask` commands is to use a virtualenv.
See [Python Packaging user guidelines](https://packaging.python.org/guides/installing-using-pip-and-virtualenv/)
for instructions on installing [`uv`](https://docs.astral.sh/uv/getting-started/installation/) to manage the virtualenv.
After installing virtualenv, you can create a virtual environment by navigating to the OpenOversight directory and
running the below:
Comment on lines +183 to +187
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the install instructions.


```shell
python3 -m virtualenv env
make env
```

Confirm you're in the virtualenv by running
Expand All @@ -202,19 +206,13 @@ deactivate
To reactivate the virtualenv, run

```shell
source env/bin/activate
source .venv/bin/activate
```

While in the virtualenv, you can install project dependencies by running

```shell
pip install -r requirements.txt
```

and

```shell
pip install -r dev-requirements.txt
make install
```

## OpenOversight Management Interface
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,15 @@ test: start

.PHONY: lint
lint:
pre-commit run --all-files
uv run pre-commit run --all-files

.PHONY: env
env:
uv venv

.PHONY: install
install:
uv pip install -r requirements.txt -r dev-requirements.txt
Comment on lines 92 to +101
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update and add make commands.


# Stop containers
.PHONY: stop
Expand Down
3 changes: 3 additions & 0 deletions OpenOversight/tests/test_functional.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import re
from unittest import skip

from flask import current_app
from playwright.sync_api import expect
Expand Down Expand Up @@ -245,6 +246,7 @@ def test_edit_officer_form_coerces_none_race_or_gender_to_not_sure(
assert selected_text == "Not Sure"


@skip("Sporadically fails, S3 mock seems wonky")
def test_image_classification_and_tagging(page, server_port, session):
test_dir = os.path.dirname(os.path.realpath(__file__))
img_path = os.path.join(test_dir, "images/200Cat.jpeg")
Expand Down Expand Up @@ -317,6 +319,7 @@ def test_image_classification_and_tagging(page, server_port, session):
assert image_box["y"] <= frame_box["y"]


@skip("Sporadically fails, S3 mock seems wonky")
def test_anonymous_user_can_upload_image(page, server_port, session):
test_dir = os.path.dirname(os.path.realpath(__file__))
img_path = os.path.join(test_dir, "images/200Cat.jpeg")
Expand Down
17 changes: 12 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ services:
createbucket:
image: minio/mc
depends_on:
- minio
minio:
condition: service_healthy
env_file:
- .env
entrypoint: >
/bin/sh -c "
sleep 5;
/usr/bin/mc config host add myminio http://minio:9000 minio ${MINIO_ROOT_PASSWORD};
/usr/bin/mc mb myminio/${S3_BUCKET_NAME};
/usr/bin/mc anonymous set public myminio/${S3_BUCKET_NAME};
Expand All @@ -43,7 +43,7 @@ services:

postgres:
restart: always
image: postgres:latest
image: postgres:17
environment:
POSTGRES_USER: openoversight
POSTGRES_PASSWORD: terriblepassword
Expand All @@ -52,15 +52,22 @@ services:
- postgres:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}" ]
interval: 10s
timeout: 5s
retries: 5

web:
restart: always
build:
context: .
dockerfile: dockerfiles/web/Dockerfile-dev
depends_on:
- postgres
- minio
minio:
condition: service_healthy
postgres:
condition: service_healthy
env_file:
- .env
environment:
Expand Down
11 changes: 9 additions & 2 deletions dockerfiles/web/Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@ WORKDIR /usr/src/app

ENV CURL_FLAGS="--proto =https --tlsv1.2 -sSf -L --max-redirs 1 -O"

ENV DEBIAN-FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the variable name: https://askubuntu.com/q/972516

ENV DISPLAY=:1
ENV PYTHONDONTWRITEBYTECODE=1

# install apt dependencies
RUN apt-get update && apt-get install -y xvfb libpq-dev python3-dev graphviz-dev graphviz && \
apt-get clean

# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh

# Add uv to PATH
ENV PATH="/root/.local/bin:$PATH"

COPY requirements.txt /usr/src/app/
RUN pip3 install --no-cache-dir -r requirements.txt

RUN uv pip install --system -r requirements.txt

COPY create_db.py test_data.py /usr/src/app/

Expand Down
16 changes: 10 additions & 6 deletions dockerfiles/web/Dockerfile-test
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ WORKDIR /usr/src/app

ENV CURL_FLAGS="--proto =https --tlsv1.2 -sSf -L --max-redirs 1 -O"

ENV DEBIAN-FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONDONTWRITEBYTECODE=1

# install apt dependencies
RUN apt-get update && apt-get install -y curl libpq-dev python3-dev && \
apt-get install -y libsqlite3-0 graphviz-dev graphviz && apt-get clean
RUN apt-get update -y && \
apt-get install -y xvfb libpq-dev python3-dev graphviz-dev graphviz && \
apt-get clean && rm -rf /var/lib/apt/lists/*

COPY requirements.txt dev-requirements.txt /usr/src/app/
# install rust and cargo so we can use jellyfish

# install rust + python dependencies via uv
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
. "$HOME/.cargo/env" && \
pip3 install --no-cache-dir -r requirements.txt && \
pip3 install --no-cache-dir -r dev-requirements.txt
curl -LsSf https://astral.sh/uv/install.sh | sh && \
export PATH="$HOME/.local/bin:$PATH" && \
uv pip install --system -r requirements.txt -r dev-requirements.txt


RUN playwright install --with-deps chromium

Expand Down
Loading