diff --git a/.github/linters/formatting.sh b/.github/linters/formatting.sh
deleted file mode 100644
index 586520af..00000000
--- a/.github/linters/formatting.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-format () {
- local checkOnly="$2";
-
- if [ "$checkOnly" = "true" ];
- then
-
- black --check --line-length 79 --target-version 'py310' --include '\.pyi?$' $1
- isort --check-only --diff --profile 'black' --multi-line 3 --trailing-comma --force-grid-wrap 0 --line-length 79 --use-parentheses $1
-
- else
-
- black --line-length 79 --target-version 'py310' --include '\.pyi?$' $1
- isort --profile 'black' --multi-line 3 --trailing-comma --force-grid-wrap 0 --line-length 79 --use-parentheses $1
- fi;
- codespell $1 --config .github/linters/.codespellrc
-}
-
-
-
diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml
index 3497584c..d27a4653 100644
--- a/.github/workflows/build_docs.yml
+++ b/.github/workflows/build_docs.yml
@@ -41,7 +41,7 @@ jobs:
micromamba install --yes -n test-env -c conda-forge paraview
python -m pip install --upgrade pip
pip install -e .
- pip install sphinx sphinx_rtd_theme sphinx-autodoc-typehints
+ pip install .[docs]
- name: Build documentation
run: |
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1e1b331c..e7fa0a11 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -37,23 +37,27 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
- - name: Install dependencies
- run: |
- pip install black
- pip install isort
- pip install codespell
+ cache: 'pip'
+
+ - name: Cache Nox
+ uses: actions/cache@v4
+ with:
+ path: .nox
+ key: ${{ runner.os }}-lint-nox-${{ hashFiles('noxfile.py') }}
+
+ - name: Install nox
+ run: pip install nox
+
- name: Formatting and sorting import
- run: |
- source .github/linters/formatting.sh
- format . true
+ run: nox -s linter
- Test-BiRD:
- name: Test-BiRD (${{ matrix.python-version }}, ${{ matrix.os }})
+ Unit-Test-BiRD:
+ name: Unit-Test-BiRD (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
- python-version: ['3.10', '3.13']
+ python-version: ['3.10', '3.14']
os: ['ubuntu-latest', 'macos-latest']
defaults:
run:
@@ -81,14 +85,15 @@ jobs:
run: |
micromamba install --yes -n test-env -c conda-forge paraview
pip install --upgrade pip
- pip install .
- pip install pytest
+ pip install --upgrade nox
+ pip install .[tests]
- name: Test
- run: pytest .
+ run: nox -s tests -- no-reports
+
- Test-pypi-Bird:
- name: Test-pypi-BiRD (${{ matrix.python-version }}, ${{ matrix.os }})
+ Unit-Test-pypi-Bird:
+ name: Unit-Test-pypi-BiRD (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@@ -120,14 +125,14 @@ jobs:
run: |
micromamba install --yes -n test-env -c conda-forge paraview
pip install --upgrade pip
- pip install nlr-bird
- pip install pytest
+ pip install --upgrade nox
+ pip install nlr-bird[tests]
- name: Test
- run: pytest .
+ run: nox -s tests -- no-reports
- Test-OF:
- name: Test-OF (${{ matrix.python-version }}, ${{ matrix.os }})
+ Regression-Test-OF:
+ name: Regression-Test-OF (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml
index 28e9b622..bdbbf1c8 100644
--- a/.github/workflows/codecov.yml
+++ b/.github/workflows/codecov.yml
@@ -24,7 +24,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
- python-version: '3.13'
+ python-version: '3.14'
cache: 'pip'
- name: Set up micromamba
@@ -42,13 +42,13 @@ jobs:
run: |
micromamba install --yes -n test-env -c conda-forge paraview
pip install --upgrade pip
- pip install pytest
- pip install pytest-cov
- pip install -e .
+ pip install --upgrade nox
+ pip install .[tests]
- name: Generate coverage report
run: |
- pytest --cov=./ --cov-report=xml:coverage.xml
+ pytest --cov=./ --cov-report=xml:coverage.xml
+
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml
index 3751c0dc..7c60ad74 100644
--- a/.github/workflows/deploy_docs.yml
+++ b/.github/workflows/deploy_docs.yml
@@ -42,8 +42,7 @@ jobs:
run: |
micromamba install --yes -n test-env -c conda-forge paraview
pip install --upgrade pip
- pip install -e .
- pip install sphinx sphinx_rtd_theme sphinx-autodoc-typehints
+ pip install -e .[docs]
- name: Build documentation
run: |
diff --git a/README.md b/README.md
index 1c1b7d87..2b38cfb2 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Bio Reactor Design (BiRD) [](https://github.com/NatLabRockies/BioReactorDesign/actions/workflows/ci.yml) [](https://pypi.org/project/NLR-bird/) [](https://app.codecov.io/gh/nrel/bioreactordesign) [](https://badge.fury.io/py/nlr-bird)
+# Bio Reactor Design (BiRD) [](https://github.com/NatLabRockies/BioReactorDesign/actions/workflows/ci.yml) [](https://pypi.org/project/NLR-bird/) [](https://app.codecov.io/gh/nrel/bioreactordesign) [](https://badge.fury.io/py/nlr-bird)
## Quick start
1. Follow the steps to install the python package (see `Installation of python package for developers` or `Installation of python package for users` below)
diff --git a/bird/requirements.txt b/bird/requirements.txt
deleted file mode 100644
index dc9584af..00000000
--- a/bird/requirements.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-numpy
-prettyPlot
-ruamel_yaml
-numpy-stl>=3.2.0
-scipy
-corner
-jax
-numpyro>=0.16.1
diff --git a/bird/version.py b/bird/version.py
index 9b518182..4a789b30 100644
--- a/bird/version.py
+++ b/bird/version.py
@@ -1,3 +1,3 @@
"""Bio reactor design version"""
-__version__ = "0.0.52"
+__version__ = "0.0.53"
diff --git a/dist.sh b/dist.sh
deleted file mode 100644
index e9df1901..00000000
--- a/dist.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-python -m build
-python -m twine upload --verbose --repository pypi dist/*
diff --git a/docs/source/contribute.rst b/docs/source/contribute.rst
index 77eede2d..28c4c0f4 100644
--- a/docs/source/contribute.rst
+++ b/docs/source/contribute.rst
@@ -12,8 +12,8 @@ You can automatically enforce the formatting guidelines with
.. code-block:: console
- pip install black isort codespell
- bash fixFormat.sh
+ pip install nox
+ nox -s lint -- write
Tests
diff --git a/fixFormat.sh b/fixFormat.sh
deleted file mode 100644
index 26867ddc..00000000
--- a/fixFormat.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-source .github/linters/formatting.sh
-
-format .
-
diff --git a/noxfile.py b/noxfile.py
new file mode 100644
index 00000000..9cb2bafc
--- /dev/null
+++ b/noxfile.py
@@ -0,0 +1,181 @@
+# noxfile.py
+
+import importlib
+import os
+import shutil
+
+import nox
+
+nox.options.sessions = []
+
+
+@nox.session(name="cleanup", python=False)
+def run_cleanup(session: nox.Session) -> None:
+ """Use os/shutil to remove some files/directories"""
+
+ if os.path.exists(".coverage"):
+ os.remove(".coverage")
+
+ if os.path.exists("reports"):
+ shutil.rmtree("reports")
+
+ folders = [".pytest_cache"]
+ for f in folders:
+ if os.path.exists(f):
+ shutil.rmtree(f)
+
+ # Recursively delete all __pycache__ folders and .pyc files
+ session.run(
+ "find",
+ ".",
+ "-type",
+ "d",
+ "-name",
+ "__pycache__",
+ "-exec",
+ "rm",
+ "-r",
+ "{}",
+ "+",
+ external=True,
+ )
+ session.run(
+ "find", ".", "-type", "f", "-name", "*.pyc", "-delete", external=True
+ )
+
+
+@nox.session(name="lint", python=False)
+@nox.session(name="linter", python=False)
+def run_lint(session: nox.Session) -> None:
+ """
+ Run black and isort with the github config file
+
+ """
+
+ session.run("pip", "install", "--upgrade", "--quiet", "black")
+ session.run("pip", "install", "--upgrade", "--quiet", "isort")
+
+ black_command = [
+ "black",
+ "--line-length",
+ "79",
+ "--target-version",
+ "py310",
+ ".",
+ ]
+ isort_command = [
+ "isort",
+ "--profile",
+ "black",
+ "--multi-line",
+ "3",
+ "--trailing-comma",
+ "--force-grid-wrap",
+ "0",
+ "--line-length",
+ "79",
+ "--use-parentheses",
+ ".",
+ ]
+
+ if not "write" in session.posargs:
+ black_command.insert(1, "--check")
+ isort_command.insert(1, "--check-only")
+ isort_command.insert(2, "--diff")
+
+ session.run(*black_command)
+ session.run(*isort_command)
+
+
+@nox.session(name="spell", python=False)
+@nox.session(name="codespell", python=False)
+def run_codespell(session: nox.Session) -> None:
+ """
+ Run codespell with the github config file
+
+ Use the optional 'write' argument to write the corrections directly into
+ the files. Otherwise, you will only see a summary of the found errors.
+
+ """
+
+ session.run("pip", "install", "--upgrade", "--quiet", "codespell")
+ command = ["codespell", "--config", ".github/linters/.codespellrc"]
+
+ if "write" in session.posargs:
+ command.append("-w")
+
+ session.run(*command)
+
+
+@nox.session(name="pypi", python=False)
+@nox.session(name="deploy", python=False)
+def run_deploy(session: nox.Session) -> None:
+ """
+ Deploy to pypi
+ """
+ session.run("pip", "install", "build")
+ session.run("pip", "install", "twine")
+ session.run("python", "-m", "build")
+ session.run(
+ "python",
+ "-m",
+ "twine",
+ "upload",
+ "--verbose",
+ "--repository",
+ "pypi",
+ "dist/*",
+ )
+
+
+@nox.session(name="tests", python=False)
+@nox.session(name="test", python=False)
+def run_pytest(session: nox.Session) -> None:
+ """
+ Run pytest and generate test/coverage reports
+
+ Use the optional 'parallel' argument to run the tests in parallel. As just
+ a flag, the number of workers will be determined automatically. Otherwise,
+ you can specify the number of workers using an int, e.g., parallel=4.
+
+ """
+
+ package = importlib.util.find_spec("bird")
+
+ if "no-reports" in session.posargs:
+ command = [
+ "pytest",
+ f"--cov=.", # for editable or site-packages
+ "tests/",
+ ]
+ else:
+ command = [
+ "pytest",
+ "--cov=bird",
+ "--cov-report=html:reports/htmlcov",
+ "--cov-report=xml:reports/coverage.xml",
+ "--junitxml=reports/junit.xml",
+ "tests/",
+ ]
+
+ for arg in session.posargs:
+ if arg.startswith("parallel="):
+ command[1:1] = ["-n", arg.split("=")[-1]]
+ elif arg.startswith("parallel"):
+ command[1:1] = ["-n", "auto"]
+ session.run(*command)
+ run_cleanup(session)
+
+
+def run_pre_commit(session: nox.Session) -> None:
+ """
+ Run all linters/tests and make new badges
+
+ Order of sessions: flake8, codespell, pytest, genbade. Using 'format' for
+ linter, 'write' for codespell, and/or 'parallel' for pytest is permitted.
+
+ """
+
+ run_lint(session)
+ run_codespell(session)
+ run_pytest(session)
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..2698850a
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,83 @@
+[build-system]
+requires = ["setuptools", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "nlr-bird"
+readme = "README.md"
+dynamic = ["version"]
+requires-python = ">=3.10,<3.15"
+license = { file = "LICENSE" }
+description = "Bio Reactor Design (BiRD): a toolbox to simulate and analyze different designs of bioreactors in OpenFOAM"
+keywords = ["meshing", "openfoam", "bioreactors"]
+authors = [
+ { name = "Malik Hassanaly" },
+ { email = "malik.hassanaly@gmail.com" },
+]
+maintainers = [
+ { name = "Malik Hassanaly" },
+ { email = "malik.hassanaly@gmail.com" },
+]
+classifiers = [
+ "Development Status :: 4 - Beta",
+ "Intended Audience :: Science/Research",
+ "Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3.12",
+ "Programming Language :: Python :: 3.13",
+ "Programming Language :: Python :: 3.14",
+]
+dependencies = [
+ "numpy",
+ "prettyPlot",
+ "ruamel_yaml",
+ "numpy-stl>=3.2.0",
+ "scipy",
+ "corner",
+ "jax",
+ "numpyro>=0.16.1",
+]
+
+[tool.setuptools.dynamic]
+version = { attr = "bird.__version__" }
+
+[tool.setuptools.packages.find]
+where = ["."]
+
+[tool.setuptools.package-data]
+"*" = ["*.yaml", "*.csv"]
+
+[project.optional-dependencies]
+docs = [
+ "sphinx",
+ "sphinx_rtd_theme",
+ "sphinx-autodoc-typehints",
+]
+tests = [
+ "pytest",
+ "pytest-cov",
+]
+calibration = [
+ "joblib",
+ "tensorflow",
+ "scikit-learn",
+ "tf2jax",
+]
+optim = [
+ "optuna",
+ "pandas",
+]
+dev = [
+ "nox",
+ "black",
+ "isort",
+ "codespell",
+ "nlr-bird[docs,tests,optim,calibration]",
+]
+
+
+[project.urls]
+Homepage = "https://github.com/NatLabRockies/BioReactorDesign"
+Documentation = "https://natlabrockies.github.io/BioReactorDesign"
+Repository = "https://github.com/NatLabRockies/BioReactorDesign"
+Issues = "https://github.com/NatLabRockies/BioReactorDesign/issues"
diff --git a/setup.py b/setup.py
deleted file mode 100644
index 6156bb46..00000000
--- a/setup.py
+++ /dev/null
@@ -1,59 +0,0 @@
-import os
-
-from setuptools import setup
-
-here = os.path.abspath(os.path.dirname(__file__))
-
-with open(os.path.join(here, "bird", "requirements.txt")) as f:
- install_requires = f.readlines()
-
-with open(os.path.join(here, "README.md"), encoding="utf-8") as f:
- readme = f.read()
-
-with open(os.path.join(here, "bird", "version.py"), encoding="utf-8") as f:
- version = f.read()
-version = version.split("=")[-1].strip().strip('"').strip("'")
-
-setup(
- name="nlr-bird",
- version=version,
- description="Bio Reactor Design (BiRD): a toolbox to simulate and analyze different designs of bioreactors in OpenFOAM",
- long_description=readme,
- long_description_content_type="text/markdown",
- url="https://github.com/NatLabRockies/BioReactorDesign",
- author="Malik Hassanaly",
- license="BSD 3-Clause",
- package_dir={"bird": "bird"},
- classifiers=[
- "Intended Audience :: Science/Research",
- "License :: OSI Approved :: BSD License",
- "Natural Language :: English",
- "Programming Language :: Python :: 3.10",
- "Programming Language :: Python :: 3.13",
- ],
- package_data={
- "": [
- "*requirements.txt",
- "*.yaml",
- ]
- },
- extras_require={
- "calibration": [
- "joblib",
- "tensorflow",
- "scikit-learn",
- "tf2jax",
- ],
- "optim": [
- "optuna",
- "pandas",
- ],
- },
- project_urls={
- "Documentation": "https://natlabrockies.github.io/BioReactorDesign/",
- "Repository": "https://github.com/NatLabRockies/BioReactorDesign",
- },
- include_package_data=True,
- python_requires=">=3.10",
- install_requires=install_requires,
-)