Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init setup #1

Merged
merged 7 commits into from
Nov 5, 2024
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
3 changes: 0 additions & 3 deletions .github/workflows/pythonapp-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jobs:
- name: lint
run: |
ruff check .
- name: type check
run: |
mypy .
- name: run tests
run: |
pytest
Expand Down
52 changes: 4 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
# reichlab-python-template
# iddata

[REPLACE WITH A DESCRIPTION OF YOUR PROJECT]

A Python template for Reich Lab projects.

This repo contains a Python package with minimal functionality. It serves as a starting point for new projects (it can be selected as the template when creating a new repo in the Reich Lab org).

There as some opinionated choices here (explained below) which people should override as needed. The main goal is to have a consistent starting point to get up and running with a new Python code base.

## Getting started

[REMOVE THIS SECTION AFTER FOLLOWING THE INSTRUCTIONS BELOW]

If you're using this repo as a template for a new project, make the following changes:

1. Rename the `reichlab_python_template` directory (under `src`) to the name of your package (no hyphens!).

2. Replace all instances of `reichlab-python-template` with the name of your repo/project.

3. Replace all instances of `reichlab_python_template` with the name of your package (remember that Python module names cannot contain hyphens).

4. Update [`pyproject.toml`](pyproject.toml). This file is required and will describe several aspects of your project. `pyproject.toml` replaces `setup.py` and is described in detail on [Python's packaging website](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/).

5. Follow the _Setup for local development_ instructions below to ensure that everything works as expected.
This is a Python module for accessing infectious disease data.


## Installing and running the package (no development)

To install this package via pip:

```bash
pip install git+[GITHUB LINK TO YOUR REPO]
```

To run it:
```bash
reichlab_python_template
pip install git+https://github.com/reichlab/iddata.git
```

## Setup for local development
Expand All @@ -58,7 +31,7 @@ Developers will be using a Python virtual environment that:
2. Change to the repo's root directory:

```bash
cd reichlab-python-template
cd iddata
```

3. Make sure the correct version of Python is currently active, and create a Python virtual environment:
Expand Down Expand Up @@ -134,20 +107,3 @@ To add or remove a project dependency:
# a handy sync option that will cleanup unused dependencies
uv pip sync requirements/requirements-dev.txt && python -m pip install -e .
```

## Opinionated notes on Python tooling

[REMOVE THIS SECTION]

The Python ecosystem is overwhelming! Current opinionated preferences, subject to change:

- To install and manage various versions of Python: [pyenv](https://github.com/pyenv/pyenv) + a local .python-version file
- To install Python packages that are available from anywhere on the machine, regardless of which Python environment is activated: [pipx](https://pipx.pypa.io/stable/)
- To create and manage Python virtual environments: [venv](https://docs.python.org/3/library/venv.html).
- It's handy having the environment packages right there in the project directory
- Most third-party tools for managing virtual environments (_e.g._, poetry, PDM, pipenv) do _too much_ and get in the way
- To generate requirements files from `pyproject.toml`: ['uv'](https://github.com/astral-sh/uv?tab=readme-ov-file#getting-started). It's new, but it's orders of magnitude faster than `pip-compile`.
- To install dependencies: uv again (again, mostly due to speed; good old pip is another fine option)
- Logging: [structlog](https://www.structlog.org/en/stable/). Python's built-in logging module is tedious.
- Linting and formatting: [ruff](https://github.com/astral-sh/ruff) because it does both and is fast.
- Pre-commit hooks: [pre-commit](https://pre-commit.com/).
24 changes: 9 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "reichlab-python-template"
description = "Python template for Reich Lab projects"
name = "iddata"
description = "Python module for accessing infectious disease data"
license = {text = "MIT License"}
readme = "README.md"
requires-python = ">=3.9"
Expand All @@ -11,27 +11,25 @@ classifiers = [
dynamic = ["version"]

dependencies = [
"structlog",
"numpy",
"pandas",
"pymmwr",
"rich",
"s3fs",
"toml"
]

[project.optional-dependencies]
dev = [
"coverage",
"freezegun",
"mypy",
"pre-commit",
"pytest",
"ruff",
"types-toml",
]

[project.urls]
Repository = "https://github.com/reichlab/reichlab-python-template.git"

[project.entry-points."console_scripts"]
reichlab_python_template = "reichlab_python_template.app:main"
Repository = "https://github.com/reichlab/iddata.git"

[build-system]
# Minimum requirements for the build system to execute.
Expand All @@ -44,11 +42,7 @@ testpaths = [
]

[tools.setuptools]
packages = ["reichlab_python_template"]

[tool.reichlab_python_template]
# to write json-formatted logs to disk, uncomment the following line specify the file location
# log_file = "/path/to/log/files/rechlab_python_template.log"
packages = ["iddata"]

[tool.ruff]
line-length = 120
Expand All @@ -61,4 +55,4 @@ inline-quotes = "double"
quote-style = "double"

[tool.setuptools.dynamic]
version = {attr = "reichlab_python_template.__version__"}
version = {attr = "iddata.__version__"}
95 changes: 68 additions & 27 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,65 +1,106 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --extra=dev --output-file=requirements/requirements-dev.txt
#
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml --extra dev -o requirements/requirements-dev.txt
aiobotocore==2.15.2
# via s3fs
aiohappyeyeballs==2.4.3
# via aiohttp
aiohttp==3.10.10
# via
# aiobotocore
# s3fs
aioitertools==0.12.0
# via aiobotocore
aiosignal==1.3.1
# via aiohttp
attrs==24.2.0
# via
# aiohttp
# pymmwr
botocore==1.35.36
# via aiobotocore
cfgv==3.4.0
# via pre-commit
coverage==7.5.1
# via python-app (pyproject.toml)
# via iddata (pyproject.toml)
distlib==0.3.8
# via virtualenv
filelock==3.14.0
# via virtualenv
freezegun==1.5.0
# via python-app (pyproject.toml)
frozenlist==1.5.0
# via
# aiohttp
# aiosignal
fsspec==2024.10.0
# via s3fs
identify==2.5.36
# via pre-commit
idna==3.10
# via yarl
iniconfig==2.0.0
# via pytest
jmespath==1.0.1
# via botocore
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
mypy==1.10.0
# via python-app (pyproject.toml)
mypy-extensions==1.0.0
# via mypy
multidict==6.1.0
# via
# aiohttp
# yarl
nodeenv==1.8.0
# via pre-commit
numpy==2.1.3
# via
# iddata (pyproject.toml)
# pandas
packaging==24.0
# via pytest
pandas==2.2.3
# via iddata (pyproject.toml)
platformdirs==4.2.1
# via virtualenv
pluggy==1.5.0
# via pytest
pre-commit==3.7.0
# via python-app (pyproject.toml)
# via iddata (pyproject.toml)
propcache==0.2.0
# via yarl
pygments==2.18.0
# via rich
pymmwr==0.2.2
# via iddata (pyproject.toml)
pytest==8.2.0
# via python-app (pyproject.toml)
# via iddata (pyproject.toml)
python-dateutil==2.9.0.post0
# via freezegun
# via
# botocore
# pandas
pytz==2024.2
# via pandas
pyyaml==6.0.1
# via pre-commit
rich==13.7.1
# via python-app (pyproject.toml)
# via iddata (pyproject.toml)
ruff==0.4.3
# via python-app (pyproject.toml)
# via iddata (pyproject.toml)
s3fs==2024.10.0
# via iddata (pyproject.toml)
setuptools==75.3.0
# via nodeenv
six==1.16.0
# via python-dateutil
structlog==24.1.0
# via python-app (pyproject.toml)
toml==0.10.2
# via python-app (pyproject.toml)
# via iddata (pyproject.toml)
types-toml==0.10.8.20240310
# via python-app (pyproject.toml)
typing-extensions==4.11.0
# via mypy
# via iddata (pyproject.toml)
tzdata==2024.2
# via pandas
urllib3==2.2.3
# via botocore
virtualenv==20.26.1
# via pre-commit

# The following packages are considered to be unsafe in a requirements file:
# setuptools
wrapt==1.16.0
# via aiobotocore
yarl==1.17.1
# via aiohttp
74 changes: 64 additions & 10 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,72 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements/requirements.txt
#
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml -o requirements/requirements.txt
aiobotocore==2.15.2
# via s3fs
aiohappyeyeballs==2.4.3
# via aiohttp
aiohttp==3.10.10
# via
# aiobotocore
# s3fs
aioitertools==0.12.0
# via aiobotocore
aiosignal==1.3.1
# via aiohttp
attrs==24.2.0
# via
# aiohttp
# pymmwr
botocore==1.35.36
# via aiobotocore
frozenlist==1.5.0
# via
# aiohttp
# aiosignal
fsspec==2024.10.0
# via s3fs
idna==3.10
# via yarl
jmespath==1.0.1
# via botocore
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
multidict==6.1.0
# via
# aiohttp
# yarl
numpy==2.1.3
# via
# iddata (pyproject.toml)
# pandas
pandas==2.2.3
# via iddata (pyproject.toml)
propcache==0.2.0
# via yarl
pygments==2.18.0
# via rich
pymmwr==0.2.2
# via iddata (pyproject.toml)
python-dateutil==2.9.0.post0
# via
# botocore
# pandas
pytz==2024.2
# via pandas
rich==13.7.1
# via python-app (pyproject.toml)
structlog==24.1.0
# via python-app (pyproject.toml)
# via iddata (pyproject.toml)
s3fs==2024.10.0
# via iddata (pyproject.toml)
six==1.16.0
# via python-dateutil
toml==0.10.2
# via python-app (pyproject.toml)
# via iddata (pyproject.toml)
tzdata==2024.2
# via pandas
urllib3==2.2.3
# via botocore
wrapt==1.16.0
# via aiobotocore
yarl==1.17.1
# via aiohttp
File renamed without changes.
Loading