-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to hatchling build system (#55)
* Bumps minimum Python version to 3.8 and minimum Pandas version to 2.0.0. * Incorporates linting via ruff, black, and isort. * Expands python-package GitHub workflow to test more OSes and Python version. * Fixes failing tests and adds new tests.
- Loading branch information
Showing
20 changed files
with
3,557 additions
and
1,698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,96 @@ | ||
# This workflow will install Python dependencies, run tests | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
# based on https://github.com/pypa/hatch/blob/master/.github/workflows/test.yml | ||
name: tests | ||
|
||
on: [ push ] | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
STABLE_PYTHON_VERSION: '3.11' | ||
PYTHONUNBUFFERED: "1" | ||
FORCE_COLOR: "1" | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: [3.7.15, 3.10.8] | ||
python-version: ["3.9", "3.10", "3.11"] | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install .[dev] --no-cache-dir | ||
|
||
- name: Ensure latest pip | ||
run: python -m pip install --upgrade pip | ||
|
||
- name: Install Hatch | ||
run: pip install hatch | ||
|
||
- name: Install vflow | ||
run: python -m pip install -e . | ||
|
||
- name: Check styles | ||
run: hatch run style:check | ||
|
||
- name: Test with pytest | ||
run: | | ||
pytest --cov=./ --cov-report=xml | ||
- name: Lint with pylint | ||
run: | | ||
pylint vflow *.py --rcfile=.pylintrc | ||
- name: "Upload coverage to Codecov" | ||
uses: codecov/codecov-action@v2 | ||
run: hatch run full | ||
|
||
- name: Disambiguate coverage filename | ||
run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}" | ||
|
||
- name: Upload coverage data | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-data | ||
path: .coverage.* | ||
|
||
coverage: | ||
name: Report coverage | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ env.STABLE_PYTHON_VERSION }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.STABLE_PYTHON_VERSION }} | ||
|
||
- name: Install Hatch | ||
run: pip install hatch | ||
|
||
- name: Download coverage data | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: coverage-data | ||
|
||
- name: Combine coverage data | ||
run: hatch run coverage:combine | ||
|
||
- name: Export coverage reports | ||
run: hatch run coverage:report-xml | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
fail_ci_if_error: true | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
VERSION ?= $(shell git rev-parse --short HEAD) | ||
CONDA_ENV_NAME ?= vflow | ||
HATCH_ENV_NAME ?= test | ||
|
||
.PHONY: build_conda_env build_ipykernel test_% run_tests fix_styles | ||
|
||
build_conda_env: | ||
conda create -n $(CONDA_ENV_NAME) -y python==3.10 pip | ||
conda run -n $(CONDA_ENV_NAME) --no-capture-output pip install -r requirements.txt | ||
conda run -n $(CONDA_ENV_NAME) --no-capture-output pip install . ipykernel | ||
|
||
build_ipykernel: | ||
conda run -n $(CONDA_ENV_NAME) python -m ipykernel install --user --name $(CONDA_ENV_NAME) --display-name "Python [conda:$(CONDA_ENV_NAME)]" | ||
|
||
test_%: | ||
hatch -v run dev $(PYTEST_ARGS) tests/test_$*.py | ||
|
||
run_tests: | ||
hatch -v run cov | ||
|
||
fix_styles: | ||
hatch -v run style:fmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# based on https://github.com/pypa/hatch/blob/master/hatch.toml | ||
|
||
[envs.default] | ||
dependencies = [ | ||
"coverage[toml]", | ||
"pytest-cov", | ||
"pytest-randomly", | ||
"pytest-rerunfailures", | ||
"pytest-xdist", | ||
] | ||
|
||
[envs.default.scripts] | ||
# --cov must not come before an argument in order to use the sources defined by config | ||
_cov = "pytest --cov --cov-report=term-missing --cov-config=pyproject.toml" | ||
dev = "pytest -p no:randomly --no-cov {args:tests}" | ||
cov = "_cov -p no:randomly {args:tests}" | ||
full = "_cov -n auto --reruns 5 --reruns-delay 3 -r aR {args:tests}" | ||
|
||
[envs.dev] | ||
template = "default" | ||
dependencies = [ | ||
"jupyterlab", | ||
"torch>=1.0.0", | ||
"torchvision", | ||
"tqdm", | ||
"scikit-learn>=0.23.0", | ||
] | ||
|
||
[envs.dev.env-vars] | ||
PIP_INDEX_URL = "https://download.pytorch.org/whl/cpu" | ||
PIP_EXTRA_INDEX_URL = "https://pypi.org/simple/" | ||
|
||
[envs.style] | ||
detached = true | ||
dependencies = [ | ||
"ruff", | ||
"black", | ||
"isort", | ||
] | ||
|
||
[envs.style.scripts] | ||
check = [ | ||
"ruff vflow tests", | ||
"black --check --diff vflow tests", | ||
"isort --check --diff --profile black vflow tests", | ||
] | ||
fmt = [ | ||
"isort --profile black ./vflow ./tests", | ||
"black ./vflow ./tests", | ||
"check", | ||
] | ||
|
||
[envs.coverage] | ||
detached = true | ||
dependencies = [ | ||
"coverage[toml]", | ||
"lxml", | ||
] | ||
|
||
[envs.coverage.scripts] | ||
combine = "coverage combine {args}" | ||
report-xml = "coverage xml -i" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,55 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
requires = ["hatchling", "hatch-requirements-txt"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "vflow" | ||
version = "0.1.2" | ||
authors = [ | ||
{ name="Chandan Singh", email="[email protected]" }, | ||
{ name="James Duncan", email="[email protected]" }, | ||
{ name="Abhineet Agarwal", email="[email protected]" }, | ||
{ name="Rush Kapoor", email="[email protected] " }, | ||
] | ||
maintainers = [ | ||
{ name="James Duncan", email="[email protected]" }, | ||
] | ||
description = "A framework for doing stability analysis with PCS." | ||
readme = "README.md" | ||
requires-python = ">=3.9" | ||
classifiers = [ | ||
"Intended Audience :: Science/Research", | ||
"Development Status :: 3 - Alpha", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3", | ||
"Topic :: Scientific/Engineering :: Artificial Intelligence", | ||
"Operating System :: OS Independent", | ||
] | ||
license = {text = "MIT"} | ||
dynamic = ["dependencies"] | ||
|
||
[project.urls] | ||
Homepage = "https://vflow.csinva.io/" | ||
Issues = "https://github.com/Yu-Group/veridical-flow/issues" | ||
|
||
[project.optional-dependencies] | ||
gpu = ["torch"] | ||
|
||
[tool.hatch.metadata] | ||
allow-direct-references = true | ||
|
||
[tool.hatch.metadata.hooks.requirements_txt] | ||
files = ["requirements.txt"] | ||
|
||
[tool.hatch.build.targets.sdist] | ||
exclude = [ | ||
"/.github", | ||
"/notebooks", | ||
] | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["vflow"] | ||
|
||
[tool.coverage.run] | ||
branch = true | ||
source_pkgs = ["vflow", "tests"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
numpy | ||
scipy | ||
matplotlib | ||
networkx | ||
pandas>=2.0.0 | ||
joblib | ||
pytest | ||
ray | ||
mlflow |
Oops, something went wrong.