From 34902848c7124601fea868d55dc99755d775d40a Mon Sep 17 00:00:00 2001 From: Malik Date: Mon, 16 Feb 2026 17:47:36 -0700 Subject: [PATCH 1/8] move to pyproj --- .github/linters/formatting.sh | 19 ---- .github/workflows/build_docs.yml | 2 +- .github/workflows/ci.yml | 40 ++++---- .github/workflows/codecov.yml | 8 +- bird/requirements.txt | 8 -- fixFormat.sh | 4 - noxfile.py | 161 +++++++++++++++++++++++++++++++ pyproject.toml | 83 ++++++++++++++++ setup.py | 59 ----------- 9 files changed, 272 insertions(+), 112 deletions(-) delete mode 100644 .github/linters/formatting.sh delete mode 100644 bird/requirements.txt delete mode 100644 fixFormat.sh create mode 100644 noxfile.py create mode 100644 pyproject.toml delete mode 100644 setup.py 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..7d141653 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,18 +37,22 @@ 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 @@ -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,13 +125,14 @@ jobs: run: | micromamba install --yes -n test-env -c conda-forge paraview pip install --upgrade pip + pip install --upgrade nox pip install nlr-bird pip install pytest - name: Test - run: pytest . + run: nox -s tests -- no-reports - Test-OF: + Regression-Test-OF: name: Test-OF (${{ matrix.python-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 28e9b622..4cfdea90 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -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/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/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..3cf6a622 --- /dev/null +++ b/noxfile.py @@ -0,0 +1,161 @@ +# 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="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("batfit") + coverage_folder = os.path.dirname(package.origin) + + if "no-reports" in session.posargs: + command = [ + "pytest", + f"--cov={coverage_folder}", # for editable or site-packages + "tests/", + ] + else: + command = [ + "pytest", + "--cov=batfit", + "--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..cef04e71 --- /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.14" +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", +] +dependencies = [ + "numpy", + "prettyPlot", + "ruamel_yaml", + "numpy-stl>=3.2.0", + "scipy", + "corner", + "jax", + "numpyro>=0.16.1", + "torchvision", +] + +[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, -) From 37f7b514d58f673253080879047b52fbbf7c370f Mon Sep 17 00:00:00 2001 From: Malik Date: Mon, 16 Feb 2026 17:52:47 -0700 Subject: [PATCH 2/8] support py3.14 --- .github/workflows/ci.yml | 2 +- .github/workflows/codecov.yml | 2 +- .github/workflows/deploy_docs.yml | 3 +-- pyproject.toml | 3 ++- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d141653..a4cdeeef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.10', '3.13'] + python-version: ['3.10', '3.14'] os: ['ubuntu-latest', 'macos-latest'] defaults: run: diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 4cfdea90..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 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/pyproject.toml b/pyproject.toml index cef04e71..48e4c03f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "nlr-bird" readme = "README.md" dynamic = ["version"] -requires-python = ">=3.10,<3.14" +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"] @@ -25,6 +25,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ] dependencies = [ "numpy", From 42d00b4c9f65dd79bec5e52b926ee139aa498dce Mon Sep 17 00:00:00 2001 From: Malik Date: Mon, 16 Feb 2026 17:54:51 -0700 Subject: [PATCH 3/8] rogue dep --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 48e4c03f..2698850a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,6 @@ dependencies = [ "corner", "jax", "numpyro>=0.16.1", - "torchvision", ] [tool.setuptools.dynamic] From ca809178c400f35eaa814f545b426b5bdcc5d53d Mon Sep 17 00:00:00 2001 From: Malik Date: Mon, 16 Feb 2026 18:06:35 -0700 Subject: [PATCH 4/8] fix cov report folder --- noxfile.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/noxfile.py b/noxfile.py index 3cf6a622..1286e8df 100644 --- a/noxfile.py +++ b/noxfile.py @@ -119,19 +119,18 @@ def run_pytest(session: nox.Session) -> None: """ - package = importlib.util.find_spec("batfit") - coverage_folder = os.path.dirname(package.origin) + package = importlib.util.find_spec("bird") if "no-reports" in session.posargs: command = [ "pytest", - f"--cov={coverage_folder}", # for editable or site-packages + f"--cov=.", # for editable or site-packages "tests/", ] else: command = [ "pytest", - "--cov=batfit", + "--cov=bird", "--cov-report=html:reports/htmlcov", "--cov-report=xml:reports/coverage.xml", "--junitxml=reports/junit.xml", From d3dac33a3d1ac218b07ccf72d52d277648ce88aa Mon Sep 17 00:00:00 2001 From: Malik Date: Mon, 16 Feb 2026 18:16:12 -0700 Subject: [PATCH 5/8] deploy in nox --- .github/workflows/ci.yml | 3 +-- bird/version.py | 2 +- dist.sh | 2 -- noxfile.py | 21 +++++++++++++++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) delete mode 100644 dist.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4cdeeef..bd4d0874 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,8 +126,7 @@ jobs: micromamba install --yes -n test-env -c conda-forge paraview pip install --upgrade pip pip install --upgrade nox - pip install nlr-bird - pip install pytest + pip install nlr-bird[tests] - name: Test run: nox -s tests -- no-reports 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/noxfile.py b/noxfile.py index 1286e8df..9cb2bafc 100644 --- a/noxfile.py +++ b/noxfile.py @@ -107,6 +107,27 @@ def run_codespell(session: nox.Session) -> None: 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: From 2836f7c9a551710bc02504d153eef1d4f2baa9a9 Mon Sep 17 00:00:00 2001 From: Malik Date: Mon, 16 Feb 2026 18:18:29 -0700 Subject: [PATCH 6/8] remove fixformat in docs --- docs/source/contribute.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 1aca9a5caaa83ceae792097244872f14382f3f88 Mon Sep 17 00:00:00 2001 From: Malik Date: Mon, 16 Feb 2026 18:19:43 -0700 Subject: [PATCH 7/8] rename reg test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd4d0874..e7fa0a11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -132,7 +132,7 @@ jobs: run: nox -s tests -- no-reports Regression-Test-OF: - name: Test-OF (${{ matrix.python-version }}, ${{ matrix.os }}) + name: Regression-Test-OF (${{ matrix.python-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false From ea4dcfea3e230a5c6df260fce11b926f030de5e6 Mon Sep 17 00:00:00 2001 From: Malik Date: Tue, 17 Feb 2026 18:43:40 -0700 Subject: [PATCH 8/8] code cov has moved with NLR name change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) [![bird-CI](https://github.com/NatLabRockies/BioReactorDesign/actions/workflows/ci.yml/badge.svg)](https://github.com/NatLabRockies/BioReactorDesign/actions/workflows/ci.yml) [![bird-pyversion](https://img.shields.io/pypi/pyversions/NLR-bird.svg)](https://pypi.org/project/NLR-bird/) [![coverage](https://codecov.io/gh/NREL/BioReactorDesign/graph/badge.svg)](https://app.codecov.io/gh/nrel/bioreactordesign) [![bird-pypi](https://badge.fury.io/py/nlr-bird.svg)](https://badge.fury.io/py/nlr-bird) +# Bio Reactor Design (BiRD) [![bird-CI](https://github.com/NatLabRockies/BioReactorDesign/actions/workflows/ci.yml/badge.svg)](https://github.com/NatLabRockies/BioReactorDesign/actions/workflows/ci.yml) [![bird-pyversion](https://img.shields.io/pypi/pyversions/NLR-bird.svg)](https://pypi.org/project/NLR-bird/) [![coverage](https://codecov.io/gh/NatlabRockies/BioReactorDesign/graph/badge.svg)](https://app.codecov.io/gh/nrel/bioreactordesign) [![bird-pypi](https://badge.fury.io/py/nlr-bird.svg)](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)