From ac86653bfb400c90884e5141f0bec92564c636e2 Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 09:29:27 +0300 Subject: [PATCH 01/13] Create conftest.py --- src/tc1d/conftest.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/tc1d/conftest.py diff --git a/src/tc1d/conftest.py b/src/tc1d/conftest.py new file mode 100644 index 0000000..c208fce --- /dev/null +++ b/src/tc1d/conftest.py @@ -0,0 +1,7 @@ +import sys + +def pytest_configure(config): + sys._called_from_test = True + +def pytest_unconfigure(config): + del sys._called_from_test From 8ffb41d3a988c6668bc4e3ea0f5de2c11799b444 Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 09:30:50 +0300 Subject: [PATCH 02/13] Update __init__.py --- src/tc1d/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tc1d/__init__.py b/src/tc1d/__init__.py index 6bd624a..0f49343 100644 --- a/src/tc1d/__init__.py +++ b/src/tc1d/__init__.py @@ -1,6 +1,12 @@ -from .tc1d import init_params, prep_model - -# Versioning import importlib.metadata +import sys +if hasattr(sys, '_called_from_test'): + # Test run, do nothing + pass +else: + # Import normally + from .tc1d import init_params, prep_model + +# Versioning __version__ = importlib.metadata.version("tc1d") From d0f85b0b4e04965c4f384aee93aa1596710b56f7 Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 09:38:02 +0300 Subject: [PATCH 03/13] Remove pytest hack --- src/tc1d/__init__.py | 9 +-------- src/tc1d/conftest.py | 7 ------- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 src/tc1d/conftest.py diff --git a/src/tc1d/__init__.py b/src/tc1d/__init__.py index 0f49343..646e7fe 100644 --- a/src/tc1d/__init__.py +++ b/src/tc1d/__init__.py @@ -1,12 +1,5 @@ import importlib.metadata -import sys - -if hasattr(sys, '_called_from_test'): - # Test run, do nothing - pass -else: - # Import normally - from .tc1d import init_params, prep_model +from .tc1d import init_params, prep_model # Versioning __version__ = importlib.metadata.version("tc1d") diff --git a/src/tc1d/conftest.py b/src/tc1d/conftest.py deleted file mode 100644 index c208fce..0000000 --- a/src/tc1d/conftest.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys - -def pytest_configure(config): - sys._called_from_test = True - -def pytest_unconfigure(config): - del sys._called_from_test From 9511477b16be53e2cf6b886407befa14eb772268 Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 09:41:23 +0300 Subject: [PATCH 04/13] Test adding mpi4py to test dependencies --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ecff3e1..09b53ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dependencies = [ [project.optional-dependencies] lint = ["mypy", "ruff"] notebook = ["jupyterlab"] -test = ["pytest"] +test = ["mpi4py", "pytest"] [project.urls] homepage = "https://tc1d.readthedocs.io/" @@ -124,3 +124,4 @@ jupyterlab = ">=4.4.7,<5" ruff = ">=0.12.12,<0.13" hatchling = ">=1.27.0,<2" mypy = ">=1.17.1,<2" +pip = ">=25.2,<26" From 9661e5f675cc060af3861d7dfb813578bfc5ff91 Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 09:46:02 +0300 Subject: [PATCH 05/13] Rename test -> tests --- .github/workflows/run-tests.yml | 2 +- noxfile.py | 6 +++--- pyproject.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8f218cb..b0f73f5 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -35,7 +35,7 @@ jobs: run: pip list - name: Run tests with pytest & nox run: | - nox -s test-${{ matrix.python-version }} + nox -s tests-${{ matrix.python-version }} # You only need to upload code coverage once to codecov unless you have a # more complex build that you need coverage for. # - name: Upload coverage to Codecov diff --git a/noxfile.py b/noxfile.py index b0dcbfa..7925ec4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,10 +1,10 @@ import nox -@nox.session(python=["3.10", "3.11", "3.12", "3.13"]) -def test(session): +@nox.session(python=["3.10", "3.11", "3.12", "3.13"]) +def tests(session): # install - session.install(".[test]") + session.install(".[tests]") # Run tests session.run("pytest") diff --git a/pyproject.toml b/pyproject.toml index 09b53ab..6285aaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dependencies = [ [project.optional-dependencies] lint = ["mypy", "ruff"] notebook = ["jupyterlab"] -test = ["mpi4py", "pytest"] +tests = ["mpi4py", "pytest"] [project.urls] homepage = "https://tc1d.readthedocs.io/" From 68b596c58a2439cb808f2a4d38d502b0fb87889f Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 09:52:46 +0300 Subject: [PATCH 06/13] Add debug output --- noxfile.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/noxfile.py b/noxfile.py index 7925ec4..d15f66d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -6,5 +6,11 @@ def tests(session): # install session.install(".[tests]") + # See what is installed + import pip # needed to use the pip functions + + for i in pip.get_installed_distributions(local_only=True): + print(i) + # Run tests session.run("pytest") From b9f55e6f960ebfa451b813ed39f561899b045d37 Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 09:56:08 +0300 Subject: [PATCH 07/13] Add debug output (another test) --- noxfile.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/noxfile.py b/noxfile.py index d15f66d..4c40b68 100644 --- a/noxfile.py +++ b/noxfile.py @@ -7,10 +7,16 @@ def tests(session): session.install(".[tests]") # See what is installed - import pip # needed to use the pip functions + import importlib.metadata - for i in pip.get_installed_distributions(local_only=True): - print(i) + distributions = importlib.metadata.distributions() + installed_packages = [] + for dist in distributions: + args = (dist.metadata["Name"], dist.version) + installed_packages.append(args) + installed_packages.sort() # Sort the packages by name + for package_name, version in installed_packages: + print(f"{package_name}=={version}") # Run tests session.run("pytest") From 53c5c99f865dbbd52bd4086f6999a35105cbcc04 Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 09:59:23 +0300 Subject: [PATCH 08/13] Add debug output (another test) --- noxfile.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/noxfile.py b/noxfile.py index 4c40b68..f3c7954 100644 --- a/noxfile.py +++ b/noxfile.py @@ -6,17 +6,6 @@ def tests(session): # install session.install(".[tests]") - # See what is installed - import importlib.metadata - - distributions = importlib.metadata.distributions() - installed_packages = [] - for dist in distributions: - args = (dist.metadata["Name"], dist.version) - installed_packages.append(args) - installed_packages.sort() # Sort the packages by name - for package_name, version in installed_packages: - print(f"{package_name}=={version}") - # Run tests + session.run("pip list") session.run("pytest") From f73f7a8c87f22ac548fdc0b1c858775d666bf0f4 Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 10:00:18 +0300 Subject: [PATCH 09/13] Add debug output (another test) --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index f3c7954..cbf0485 100644 --- a/noxfile.py +++ b/noxfile.py @@ -7,5 +7,5 @@ def tests(session): session.install(".[tests]") # Run tests - session.run("pip list") + session.run("python -m pip list") session.run("pytest") From 7efec8bdcebaad0c86270bc58dec0d600854cceb Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 10:04:02 +0300 Subject: [PATCH 10/13] Add debug output (another test) --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index cbf0485..4fa1529 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,7 +5,7 @@ def tests(session): # install session.install(".[tests]") + session.install("mpi4py") # Run tests - session.run("python -m pip list") session.run("pytest") From 6542e8da70ff469cc13b3334f31d9b385e0af5dd Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 10:09:34 +0300 Subject: [PATCH 11/13] Try another MPI install option --- noxfile.py | 1 - pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index 4fa1529..7925ec4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,7 +5,6 @@ def tests(session): # install session.install(".[tests]") - session.install("mpi4py") # Run tests session.run("pytest") diff --git a/pyproject.toml b/pyproject.toml index 6285aaf..d8a144c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dependencies = [ [project.optional-dependencies] lint = ["mypy", "ruff"] notebook = ["jupyterlab"] -tests = ["mpi4py", "pytest"] +tests = ["mpi4py", "openmpi", "pytest"] [project.urls] homepage = "https://tc1d.readthedocs.io/" From aa464073bd4729a6ae914d5377fd4e37570b8dcd Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 10:10:53 +0300 Subject: [PATCH 12/13] Update package dependencies --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index d8a144c..b566e62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ dependencies = [ "mpi4py", "neighpy", "numpy", + "openmpi", "schwimmbad", "scipy", "scikit-learn", From 870f4578f4e13f732b04bbe8a17bc04c79c5e1aa Mon Sep 17 00:00:00 2001 From: Dave Whipp Date: Wed, 17 Sep 2025 10:22:10 +0300 Subject: [PATCH 13/13] Exclude windows from tests for now due to MPI issue --- .github/workflows/run-tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b0f73f5..ebb97b2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -18,7 +18,9 @@ jobs: strategy: fail-fast: false matrix: - os: ["ubuntu-latest", "macos-latest", "windows-latest"] + # Exclude Windows for now since it causes MPI issues + # os: ["ubuntu-latest", "macos-latest", "windows-latest"] + os: ["ubuntu-latest", "macos-latest"] python-version: ["3.10", "3.11", "3.12", "3.13"] steps: