Skip to content

Commit

Permalink
Merge pull request #232 from nationalarchives/poetize
Browse files Browse the repository at this point in the history
Use poetry
  • Loading branch information
jacksonj04 authored Oct 30, 2023
2 parents 48d03b1 + a8d6fd1 commit e3bc8a5
Show file tree
Hide file tree
Showing 8 changed files with 789 additions and 83 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: pip
cache-dependency-path: requirements.txt
python-version: "3.12"

- name: Run pre-commit
uses: pre-commit/[email protected]
Expand All @@ -48,12 +46,15 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: pip
cache-dependency-path: requirements.txt
python-version: "3.12"

- name: Install requirements
run: pip install -r requirements.txt
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.6.1

- name: Install dependencies
run: poetry install

- name: Run test
run: script/test
run: poetry run script/test
1 change: 0 additions & 1 deletion .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ README.md
docker-compose.yaml
openapi.yaml
pyproject.toml
requirements.txt
setup.cfg
src/openapi_server/apis/__init__.py
src/openapi_server/apis/reading_api.py
Expand Down
35 changes: 11 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
FROM python:3.12 AS builder
FROM python:3.12 as service

WORKDIR /usr/src/app
RUN pip install poetry==1.6.1

RUN python3 -m venv /venv
ENV PATH="/venv/bin:$PATH"
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1

RUN pip install --upgrade pip
WORKDIR /app

COPY . .
RUN pip install -r requirements.txt --no-cache-dir .
COPY pyproject.toml poetry.lock ./

RUN poetry install --without dev --no-root

FROM python:3.12 AS test_runner
WORKDIR /tmp
COPY --from=builder /venv /venv
COPY --from=builder /usr/src/app/tests tests
ENV PATH=/venv/bin:$PATH

# install test dependencies
RUN pip install pytest

# run tests
RUN pytest tests


FROM python:3.12 AS service
WORKDIR /root/app/site-packages
COPY --from=test_runner /venv /venv
ENV PATH=/venv/bin:$PATH
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
COPY src .
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ Exposing an API to archived case law.

## Requirements.

Python >= 3.8
Python >= 3.12

## Installation & Usage

Ensure that the `MARKLOGIC_API_CLIENT_HOST` environment is set to point at the Marklogic server.

Consider using a virtual environment via ```virtualenv -p `which python` ```
Consider importing prerequisites via `pip install -r requirements.txt`
This project uses [Poetry](https://python-poetry.org/) to manage dependencies. You can install them with `poetry install`, and access a virtual environment with `poetry shell`.

To run the server, run `script/server`; open `http://localhost:8080/` in a browser

Expand Down
736 changes: 736 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

31 changes: 28 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"


[tool.black]
line-length = 88
Expand Down Expand Up @@ -28,3 +26,30 @@ skip = [
'.venv', '_build', 'buck-out', 'build', 'dist', 'node_modules', 'venv',
]
skip_gitignore = true

[tool.poetry]
name = "ds-caselaw-privileged-api"
version = "0.3.0"
description = ""
authors = ["David McKee <[email protected]>"]
license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.12, <4"
fastapi = ">=0.103.2"
python-dotenv = ">=1.0.0"
ds-caselaw-marklogic-api-client = ">=5.2.0"
django-environ = ">=0.11.2"
requests = {extras = ["use-chardet-on-py3"], version = ">=2.31.0"}
requests-toolbelt = ">=1.0.0"
lxml = ">= 4.9.3"
httpx = ">= 0.25.0"
uvicorn = ">= 0.23.2"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
43 changes: 0 additions & 43 deletions requirements.txt

This file was deleted.

2 changes: 2 additions & 0 deletions script/test
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#! /bin/bash

export $(cat .env|xargs)
PYTHONPATH=src pytest tests $*

0 comments on commit e3bc8a5

Please sign in to comment.