Skip to content
Merged
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
8 changes: 6 additions & 2 deletions .bumpversion.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ setup_hooks = []
pre_commit_hooks = []
post_commit_hooks = []


[[tool.bumpversion.files]]
filename = "my_project_template/__init__.py"
filename = "src/my_project_template/__init__.py"
search = "__version__ = \"{current_version}\""
replace = "__version__ = \"{new_version}\""

Expand All @@ -35,3 +34,8 @@ replace = "version = \"{new_version}\""
filename = "api-spec.yaml"
search = "version: {current_version}"
replace = "version: {new_version}"

[[tool.bumpversion.files]]
filename = "Makefile"
search = "VERSION := {current_version}"
replace = "VERSION := {new_version}"
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.git
.github
.eggs/
build
Expand All @@ -6,9 +7,9 @@ dist
*.egg-info
tests
venv
.venv

__pycache__
*.pyc
*.pyo
*.pyd
*.output
Expand Down
16 changes: 1 addition & 15 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,13 @@ A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error


**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
10 changes: 0 additions & 10 deletions .github/workflows/black.yml

This file was deleted.

44 changes: 23 additions & 21 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: BDD and Unit Tests

on:
Expand All @@ -10,24 +7,29 @@ on:
branches: [ master ]

jobs:
build:

run-tests:
name: python
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-tests.txt ]; then pip install -r requirements-tests.txt; fi
- name: Test with pytest
run: |
pytest
- name: Run BDD Tests
run: |
behave
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
# Install a specific version of uv.
version: "0.8.15"

- name: Install the project
run: uv sync --locked --group=test

- name: Run pytests
run: uv run pytest

- name: Run BDD Tests
run: uv run behave
20 changes: 20 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff

# Update output format to enable automatic inline annotations.
- name: Run Ruff
run: ruff check --output-format=github .
36 changes: 33 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
FROM python:3.13-slim-trixie

FROM python:3.13-slim-trixie AS builder
LABEL MAINTAINER="Pradeep Bashyal"

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
ENV UV_PYTHON_PREFERENCE=only-managed

WORKDIR /app
# Install everything except the package
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project --group deploy

# Sync so that Python version is installed
COPY . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --group deploy && uv build


# Final Docker Image
FROM python:3.13-slim-trixie

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /app

# Copy the Python packages
COPY --from=builder /app/.venv /app/.venv

COPY --from=builder /app/dist/my_project_template-0.0.1-py3-none-any.whl /tmp/
RUN python3 -m pip install /tmp/my_project_template-0.0.1-py3-none-any.whl

COPY app.py /app/
COPY api.py /app/
COPY api-spec.yaml /app/
COPY my_project_template /app/my_project_template
COPY run-app.sh /app/

# Put the uv built Python packages in the PATH
ENV PYTHONPATH="/app/.venv/lib/python3.13/site-packages/:"

# Sync the project into a new environment, asserting the lockfile is up to date
COPY pyproject.toml /app/
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ lint: ## check style with ruff
uv tool run ruff check

behave: clean-test ## run the behave tests, generate and serve report
- uv run behave -f allure_behave.formatter:AllureFormatter -o allure_report
uv run behave -f allure_behave.formatter:AllureFormatter -o allure_report
allure serve allure_report

pytest: clean-test ## run tests quickly with the default Python
Expand Down Expand Up @@ -86,7 +86,6 @@ docker: docker-build ## build a docker image and run the service

sync: clean ## install the package to the active Python's site-packages
uv sync --all-groups
pre-commit install

install: sync ## Sync pyproject.toml to .venv as well as install tools
pre-commit install
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[build-system]
requires = ["uv_build>=0.8.15,<0.9.0"]
build-backend = "uv_build"

[project]
name = "nmdp-python-project-template"
name = "my_project_template"
version = "0.0.1"
description="Python Project Template. Standardized Python project structure for NMDP projects"
requires-python = ">=3.13"
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/test_my_project_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"""Tests for `my_project_template` package."""

import pytest
from my_project_template.algorithm.match import slug_match
from my_project_template.model.slug import SLUG
from my_project_template.model.allele import Allele


@pytest.fixture
Expand All @@ -40,3 +43,25 @@ def supported_genes():
def test_content(supported_genes):
"""Sample pytest test function with the pytest fixture as an argument."""
assert "HLA-A" in supported_genes


def test_slug_match_identical_slugs():
"""Test that identical SLUGs match."""
allele1 = Allele("HLA-A", "HLA-A*01:01")
allele2 = Allele("HLA-A", "HLA-A*02:01")
slug1 = SLUG(allele1, allele2)
slug2 = SLUG(allele1, allele2)

assert slug_match(slug1, slug2) is True


def test_slug_match_different_slugs():
"""Test that different SLUGs do not match."""
allele1 = Allele("HLA-A", "HLA-A*01:01")
allele2 = Allele("HLA-A", "HLA-A*02:01")
allele3 = Allele("HLA-A", "HLA-A*03:01")

slug1 = SLUG(allele1, allele2)
slug2 = SLUG(allele1, allele3)

assert slug_match(slug1, slug2) is False
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.