Skip to content

Commit

Permalink
📦 PDM (#15)
Browse files Browse the repository at this point in the history
Replaces Poetry with PDM for dependency resolution

* Migrates to PDM for PEP 621 support
* Test with new pytest pip workflow
* Revert to pytest main branch with new installer
* Test with new pdm docs workflow
* Allow running docs manually
* Pin mike to version fixing deprication warnings
  • Loading branch information
mrharpo authored Apr 3, 2023
1 parent 196cfcb commit 69f9be1
Show file tree
Hide file tree
Showing 10 changed files with 2,547 additions and 1,849 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pdm.toml
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 📖 Docs

on:
workflow_dispatch:
push:
branches:
- main
Expand All @@ -9,4 +10,4 @@ on:
jobs:
build:
name: 📓 Build and deploy docs
uses: WGBH-MLA/.github/.github/workflows/docs.yml@main
uses: WGBH-MLA/.github/.github/workflows/docs.yml@pdm
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@ __pycache__

# Development sqlite db
*.sqlite

# Local pdm config
.pdm.toml

# PEP 582 local files
__pypackages__/

# Docs site
site/
37 changes: 22 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,54 @@
FROM python as base
# Set working dir to /app, where all Chowda code lives.
WORKDIR /app
# Install uvicorn (ASGI web server) and poetry (dependency manager) using pip.
RUN pip install -U pip uvicorn poetry
RUN pip install -U pip
# Copy app code to container
COPY pyproject.toml poetry.lock README.md ./
COPY pyproject.toml pdm.lock README.md ./
COPY chowda chowda

###########################
# 'dev' build stage
###########################
FROM base as dev

# Install dev dependencies with poetry
RUN poetry install -n --with dev
# Install PDM dependency manager
RUN pip install pdm
# Configure pdm to instal dependencies into ./__pypyackages__/
RUN pdm config python.use_venv false
# Configure python to use pep582 with local __pypyackages__
ENV PYTHONPATH=/usr/local/lib/python3.11/site-packages/pdm/pep582
# Add local packages to $PATH
ENV PATH=$PATH:/app/__pypackages__/3.11/bin/

# Install dev dependencies with pdm
RUN pdm install -G dev
# Start dev server.
CMD poetry run uvicorn chowda:app --host 0.0.0.0 --reload
CMD uvicorn chowda:app --host 0.0.0.0 --reload --log-level debug


###########################
# 'test' build stage
###########################
FROM dev as test
FROM base as test
# Install test requiremens with poetry
COPY chowda chowda
RUN poetry install -n --with test
# Copy the test code
COPY tests tests
# Install test dependencies
RUN pip install .[test]
# Run the tests
CMD poetry run pytest -v -n auto
CMD pytest -v -n auto


###########################
# 'locust' build stage for load testing
############################
FROM test as locust
RUN pip install locust
RUN pip install .[locust]
CMD poetry run locust


###########################
# 'production' build stage
############################
FROM base as production
COPY chowda chowda
RUN poetry install --with production
CMD poetry run uvicorn chowda:app --host 0.0.0.0
RUN pip install .[production]
CMD gunicorn chowda:app -b 0.0.0.0:8000 -w 2 --worker-class uvicorn.workers.UvicornWorker
2 changes: 1 addition & 1 deletion chowda/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.1'
__version__ = '0.1.0'
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ A CLAMS processing app

## Credits

Created by WGBH-MLA
Created by WGBH-MLA for the [CLAMS project](https://clams.ai/)
Loading

0 comments on commit 69f9be1

Please sign in to comment.