Repository: DiamondLightSource/httomo (language: python)

Issue:
working conda recipe



Discussion / hints:

Fix patch:
diff --git a/conda/environment.yml b/conda/environment.yml
index 4a46adbd2..e5a0ba8ae 100644
--- a/conda/environment.yml
+++ b/conda/environment.yml
@@ -19,3 +19,4 @@ dependencies:
   - conda-forge::tomopy
   - httomo::larix
   - httomo::tomobar
+  - httomo::httomolib


Test patch:
diff --git a/.github/workflows/cpu_tests.yml b/.github/workflows/cpu_tests.yml
new file mode 100644
index 000000000..9ecf52f0a
--- /dev/null
+++ b/.github/workflows/cpu_tests.yml
@@ -0,0 +1,43 @@
+name: httomo CPU tests
+
+on:
+  push:
+    branches:
+      - main
+  pull_request:
+    branches:
+      - main
+
+jobs:
+  build-linux:
+    runs-on: ubuntu-latest
+
+    defaults:
+      run:
+        shell: bash -l {0}
+
+    steps:
+      - name: Checkout repository code
+        uses: actions/checkout@v2
+
+      # setup Python 3.9
+      - name: Setup Python 3.9
+        uses: actions/setup-python@v2
+        with:
+          python-version: 3.9
+
+      # install dependencies with conda
+      - name: Install dependencies with conda
+        run: |
+          conda env create --name httomo --file conda/environment.yml
+          conda activate httomo
+          conda run -n httomo pip install -e .
+          conda run -n httomo pip install httomolib
+          conda env list
+          conda list
+
+      # run tests
+      - name: Run CPU tests (No CUDA drivers needed)
+        run: |
+          conda run -n httomo pip install pytest
+          conda run -n httomo pytest -m "not cupy"
diff --git a/tests/conftest.py b/tests/conftest.py
index 772c953ae..54be94e49 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -12,6 +12,7 @@
 def pytest_configure(config):
     config.addinivalue_line("markers", "mpi: mark test to run in an MPI environment")
     config.addinivalue_line("markers", "perf: mark test as performance test")
+    config.addinivalue_line("markers", "cupy: needs cupy to run")
 
 
 def pytest_addoption(parser):
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 8ee097797..7368b62f2 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1,14 +1,17 @@
+import pytest
 import subprocess
 import sys
 
 from httomo import __version__
 
 
+@pytest.mark.cupy
 def test_cli_version_shows_version():
     cmd = [sys.executable, "-m", "httomo", "--version"]
     assert __version__ == subprocess.check_output(cmd).decode().strip()
 
 
+@pytest.mark.cupy
 def test_cli_help_shows_help():
     cmd = [sys.executable, "-m", "httomo", "--help"]
     assert (
@@ -19,6 +22,7 @@ def test_cli_help_shows_help():
     )
 
 
+@pytest.mark.cupy
 def test_cli_noargs_raises_error():
     cmd = [sys.executable, "-m", "httomo"]
     try:
diff --git a/tests/test_loader.py b/tests/test_loader.py
index a5fc66fa1..8410324aa 100644
--- a/tests/test_loader.py
+++ b/tests/test_loader.py
@@ -1,6 +1,8 @@
+import pytest
 import subprocess
 
 
+@pytest.mark.cupy
 def test_tomo_standard_testing_pipeline_loaded(
     cmd, standard_data, standard_loader, output_folder, testing_pipeline, merge_yamls
 ):
@@ -22,6 +24,7 @@ def test_tomo_standard_testing_pipeline_loaded(
     assert "Pipeline finished" in result.stderr
 
 
+@pytest.mark.cupy
 def test_diad_testing_pipeline_loaded(
     cmd, diad_data, diad_loader, output_folder, testing_pipeline, merge_yamls
 ):
diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py
index dc756d968..c4f355848 100644
--- a/tests/test_pipeline.py
+++ b/tests/test_pipeline.py
@@ -4,6 +4,7 @@
 
 import h5py
 import numpy as np
+import pytest
 from numpy.testing import assert_allclose
 from PIL import Image
 import glob
@@ -33,6 +34,7 @@ def read_folder(folder):
     return files
 
 
+@pytest.mark.cupy
 def test_tomo_standard_testing_pipeline_output(
     cmd, standard_data, standard_loader, testing_pipeline, output_folder, merge_yamls
 ):
@@ -87,6 +89,7 @@ def test_tomo_standard_testing_pipeline_output(
     assert "INFO | ~~~ Pipeline finished ~~~" in log_contents
 
 
+@pytest.mark.cupy
 def test_tomo_standard_testing_pipeline_output_with_save_all(
     cmd, standard_data, standard_loader, testing_pipeline, output_folder, merge_yamls
 ):
@@ -124,6 +127,7 @@ def test_tomo_standard_testing_pipeline_output_with_save_all(
                 np.testing.assert_almost_equal(np.sum(f["data"]), -362.73358, decimal=4)
 
 
+@pytest.mark.cupy
 def test_diad_testing_pipeline_output(
     cmd, diad_data, diad_loader, testing_pipeline, output_folder, merge_yamls
 ):
@@ -184,6 +188,7 @@ def test_diad_testing_pipeline_output(
     assert "INFO | ~~~ Pipeline finished ~~~" in log_contents
 
 
+@pytest.mark.cupy
 def test_sweep_range_pipeline_with_step_absent(
     cmd, standard_data, sample_pipelines, output_folder
 ):