Skip to content

Commit

Permalink
use poetry (#43)
Browse files Browse the repository at this point in the history
Update repo to use poetry (ticket #41)

Changes:
- Removed requirements.txt
- Removed setup.cfg
- Updated devcontainer's dockerfile to use poetry (instead of pip)
- Created pyproject containing requirements and setup.cfg content
- Created poetry.lock
- Updated few comments in phase_validations and schema_template (that
were not formatted properly).
- Updated github-actions tests to use poetry (instead of pip)

Tests:
- Validate that we still able to execute python through VSCode
- Validate that we still able to run Tests through VSCode
- Passed linters
- Passed unit-tests

---------

Co-authored-by: Aldrian Harjati <[email protected]>
  • Loading branch information
aharjati and Aldrian Harjati authored Sep 13, 2023
1 parent 2eaf1ae commit 1c75d8e
Show file tree
Hide file tree
Showing 15 changed files with 868 additions and 491 deletions.
22 changes: 12 additions & 10 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
FROM continuumio/miniconda3:master-alpine
FROM python:3.11-alpine

LABEL maintainer="Ethan Bienstock"
LABEL maintainer="CFPB RegTech Team"

COPY requirements.txt .

ENV PATH /opt/conda/bin:$PATH
COPY ../pyproject.toml .
COPY ../poetry.lock .

# install git and alpine sdk for c compiler extensions
RUN apk add --update git curl alpine-sdk
RUN apk add --update git curl

# install pip dependencies
RUN pip install --upgrade pip && \
pip install -r requirements.txt && \
rm requirements.txt
RUN pip install --upgrade pip & \
pip install poetry

# run poetry install
RUN poetry config virtualenvs.create false
RUN poetry install --no-root

# create a non root sbl user
ARG USER=sbl
Expand All @@ -29,4 +31,4 @@ RUN adduser -D $USER \
ENV PATH="/home/sbl/.local/bin:${PATH}"

USER $USER
WORKDIR $HOME
WORKDIR $HOME
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"build": {
"dockerfile": "Dockerfile"
"dockerfile": "Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
Expand Down
6 changes: 0 additions & 6 deletions .devcontainer/requirements.txt

This file was deleted.

6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f .devcontainer/requirements.txt ]; then pip install -r .devcontainer/requirements.txt; fi
pip install poetry
poetry config virtualenvs.create false
poetry install --no-root
- name: Launch tests & generate report
run: pytest
run: poetry run pytest
- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ __pycache__
.DS_Store
.ruff_cache/

#pytest
.coverage
coverage.xml

# excel artifact
~$example_sblar.xlsx
645 changes: 645 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[tool.poetry]
name = "regtech-data-validator"
version = "0.1.0"
description = "RegTech submission data parser and validator"
authors = []
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
pandas = "2.1.0"
pandera = "0.16.1"

[tool.poetry.group.dev.dependencies]
pytest = "7.4.0"
pytest-cov = "4.1.0"
black = "23.3.0"
ruff = "0.0.259"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

# Black formatting
[tool.black]
preview = true
line-length = 120
skip-string-normalization = true
include = '\.pyi?$'
exclude = '''
/(
| .devcontainer
| .git
| .gitignore
| .github
| data
| tools
)/
'''

# Linting
[tool.ruff]
# Same as Black.
line-length = 120

# Testing
[tool.pytest.ini_options]
addopts = [
"--cov-report=term-missing",
"--cov-branch",
"--cov-report=xml",
"--cov-report=term",
"--cov=src",
"-vv",
"--strict-markers",
"-rfE",
]
testpaths = [
"src/tests",
]

[tool.coverage.run]
relative_files = true
source = ["src"]

[tool.coverage.report]
skip_empty = true
10 changes: 0 additions & 10 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 1c75d8e

Please sign in to comment.