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
37 changes: 37 additions & 0 deletions .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[tool.bumpversion]
current_version = "0.0.1"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
replace = "{new_version}"
regex = false
ignore_missing_version = false
ignore_missing_files = false
tag = false
sign_tags = false
tag_name = "v{new_version}"
tag_message = "Bump version: {current_version} → {new_version}"
allow_dirty = false
commit = false
message = "Bump version: {current_version} → {new_version}"
moveable_tags = []
commit_args = ""
setup_hooks = []
pre_commit_hooks = []
post_commit_hooks = []


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

[[tool.bumpversion.files]]
filename = "pyproject.toml"
search = "version = \"{current_version}\""
replace = "version = \"{new_version}\""

[[tool.bumpversion.files]]
filename = "api-spec.yaml"
search = "version: {current_version}"
replace = "version: {new_version}"
28 changes: 5 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
.ruff_cache/

# Translations
*.mo
Expand All @@ -65,39 +66,16 @@ db.sqlite3-journal
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

Expand All @@ -110,6 +88,9 @@ ENV/
env.bak/
venv.bak/

# Mac
.DS_Store

# IDEs
# Spyder project settings
.spyderproject
Expand All @@ -134,3 +115,4 @@ dmypy.json
# behave
pretty.output
allure_report/

23 changes: 11 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.12.12
hooks:
# Run the linter.
- id: ruff-check
types_or: [python, pyi]
args: [--fix]
# Run the formatter.
- id: ruff-format
types_or: [python, pyi]
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
FROM python:3.11-slim-buster
FROM python:3.13-slim-trixie

LABEL MAINTAINER="Pradeep Bashyal"

WORKDIR /app

COPY requirements.txt /app
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

COPY requirements-deploy.txt /app
RUN pip install --no-cache-dir -r requirements-deploy.txt
WORKDIR /app

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

CMD ["gunicorn" , "--bind", "0.0.0.0:8080", "--worker-tmp-dir", "/dev/shm", "app:app"]
# Sync the project into a new environment, asserting the lockfile is up to date
COPY pyproject.toml /app/
COPY uv.lock /app/
RUN /bin/uv sync --locked --group deploy

CMD [".venv/bin/gunicorn" , "--bind", "0.0.0.0:8080", "--worker-tmp-dir", "/dev/shm", "app:app"]
8 changes: 0 additions & 8 deletions HISTORY.rst

This file was deleted.

47 changes: 20 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PROJECT_NAME := $(shell basename `pwd`)
PACKAGE_NAME := my_project_template
VERSION := 0.0.1

.PHONY: clean clean-test clean-pyc clean-build docs help test test-all
.DEFAULT_GOAL := help
Expand Down Expand Up @@ -53,56 +54,48 @@ clean-test: ## remove test and coverage artifacts
rm -fr .pytest_cache
rm -fr allure_report

lint: ## check style with flake8
# stop the build if there are Python syntax errors or undefined names \
exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 $(PACKAGE_NAME) tests --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 $(PACKAGE_NAME) --exit-zero --max-complexity=10 --max-line-length=127 --statistics
lint: ## check style with ruff
uv tool run ruff check

behave: clean-test ## run the behave tests, generate and serve report
- 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
PYTHONPATH=. pytest
uv run pytest

test: clean-test ## run all(BDD and unit) tests
PYTHONPATH=. pytest
behave
uv run pytest
uv run behave

coverage: ## check code coverage quickly with the default Python
coverage run --source my_project_template -m pytest
coverage run --source $(PACKAGE_NAME) -m pytest
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html

dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
uv build
ls -l dist

docker-build: ## build a docker image for the service
docker build -t my-project-template-service:0.0.1 .
docker build -t $(PACKAGE_NAME):$(VERSION) .

docker: docker-build ## build a docker image and run the service
docker run --name my-project-template -p 8080:8080 my-project-template-service:0.0.1

install: clean ## install the package to the active Python's site-packages
pip install --upgrade pip setuptools
python setup.py install
pip install -r requirements.txt
pip install -r requirements-tests.txt
pip install -r requirements-dev.txt
pip install -r requirements-deploy.txt
docker run --name $(PACKAGE_NAME) -p 8080:8080 $(PACKAGE_NAME):$(VERSION)

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
uv tool install bump-my-version

venv: ## creates a Python3 virtualenv environment in venv
python3 -m venv venv --prompt $(PROJECT_NAME)-venv
@echo "====================================================================="
@echo "To activate the new virtual environment, execute the following from your shell"
@echo "source venv/bin/activate"
uv venv --prompt $(PROJECT_NAME)-venv

activate: ## activate a virtual environment. Run `make venv` before activating.
@echo "====================================================================="
@echo "To activate the new virtual environment, execute the following from your shell"
@echo "source venv/bin/activate"
@echo "source .venv/bin/activate"
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

app = connexion.App(__name__)
application = app.app
api = app.add_api("api-spec.yaml")
app.add_api("api-spec.yaml")


@app.route("/")
def index():
return redirect(api.base_path + "/ui")
return redirect("/ui")


if __name__ == "__main__":
app.run(port=8080, debug=True)
app.run(port=8080)
72 changes: 72 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[project]
name = "nmdp-python-project-template"
version = "0.0.1"
description="Python Project Template. Standardized Python project structure for NMDP projects"
requires-python = ">=3.13"
dependencies = [
]
authors = [
{name = "Pradeep Bashyal", email = "[email protected]"},
{name = "NMDP Person"},
{email = "[email protected]"},
]
maintainers = [
{name = "Pradeep Bashyal", email = "[email protected]"},
]
readme = "README.md"
license = "LGPL-3.0-only"
keywords = ["HLA", "matching"]
classifiers = [
# Prevent a package from being uploaded to PyPI
# "Private :: Do Not Upload"

# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 2 - Pre-Alpha",

# Indicate who your project is intended for
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",

# Specify the Python versions you support here.
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]

[project.urls]
Homepage = "https://nmdp-bioinformatics.org/"
Documentation = "https://github.com/nmdp-bioinformatics/nmdp-python-project-template/README.md"
Repository = "https://github.com/nmdp-bioinformatics/nmdp-python-project-template"
Issues = "https://github.com/nmdp-bioinformatics/nmdp-python-project-template/issues"
Changelog = "https://github.com/nmdp-bioinformatics/nmdp-python-project-template/blob/master/CHANGELOG.md"

[dependency-groups]
dev = [
"pre-commit>=4.2.0",
"ruff>=0.11.11",
"allure-behave==2.15.0",
"coverage==7.10.6",
]

test = [
"pytest==8.4.2",
"behave==1.3.3",
"pyhamcrest==2.1.0",
]

deploy=[
"connexion[swagger-ui,flask,uvicorn]==3.2.0",
"gunicorn==23.0.0"
]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
testpaths = [
"tests",
]

[tool.ruff]
exclude = [".git", ".venv", "tests",]
2 changes: 0 additions & 2 deletions requirements-deploy.txt

This file was deleted.

6 changes: 0 additions & 6 deletions requirements-dev.txt

This file was deleted.

3 changes: 0 additions & 3 deletions requirements-tests.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

22 changes: 0 additions & 22 deletions setup.cfg

This file was deleted.

Loading
Loading