CIL icon indicating copy to clipboard operation
CIL copied to clipboard

New environment files for installing tested environments with CIL

Open hrobarts opened this issue 9 months ago • 4 comments

Description

Make environment files for installation

  • [x] Basic CIL installation with a tested version of python and numpy
  • [x] CIL installation plus packages needed for demos Tested demos using pytest --nbmake --nbmake-find-import-errors --nbmake-timeout=20 *.ipynb
  • [x] CIL installation plus packages needed for tests Ran tests on windows and linux

Closes #2090

Example Usage

:heart: Thanks for your contribution!

hrobarts avatar Mar 06 '25 16:03 hrobarts

This might take some thinking about. Considering first the basic cil_env.yml, it installs cil=24.3.0.

Below are my outputs (truncated), running the v24.3.0 tests. It seems we need to add a skimage skip, and I believe we knew the test_bb_converge was having windows issues on release.

I think this means potentially we need a cil_env_dev.yml, cil_demos_dev.yml, cil_tests_dev.yml that create the environment, and run GHA in CI. This will ensure that as we add tests they get correctly run or skipped depending on the environment. This is potentially as simple as toggling ccpi::cil to ccpi/label/dev::cil in the files.

Separately we could have periodic tests to confirm this tagged environment can still be created and pass tests. The tests that need to pass are those from the associated tag.

v24.3.0 tests:

----------------------------------------------------------------------
TEST SYSTEM CONFIGURATION
CIL version:  24.3.0
{'has_astra': False,
 'has_ccpi_regularisation': False,
 'has_cvxpy': False,
 'has_ipp': True,
 'has_numba': True,
 'has_nvidia': True,
 'has_tigre': False,
 'has_tomophantom': False}
----------------------------------------------------------------------



======================================================================
ERROR: test_reconstructors (unittest.loader._FailedTest.test_reconstructors)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_reconstructors
Traceback (most recent call last):
  File "C:\Users\tpc56154\miniforge3\envs\cil\Lib\unittest\loader.py", line 396, in _find_test_path
    module = self._get_module_from_name(name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tpc56154\miniforge3\envs\cil\Lib\unittest\loader.py", line 339, in _get_module_from_name
    __import__(name)
  File "C:\Users\tpc56154\GitHub\CIL\Wrappers\Python\test\test_reconstructors.py", line 23, in <module>
    from skimage.transform.radon_transform import _get_fourier_filter as skimage_get_fourier_filter
ModuleNotFoundError: No module named 'skimage'


======================================================================
FAIL: test_bb_converge (test_stepsizes.TestStepSizeBB.test_bb_converge)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\tpc56154\GitHub\CIL\Wrappers\Python\test\test_stepsizes.py", line 303, in test_bb_converge
    self.assertNumpyArrayAlmostEqual(alg.x.as_array(), alg_true.x.as_array(), decimal=2)
  File "C:\Users\tpc56154\GitHub\CIL\Wrappers\Python\test\testclass.py", line 60, in assertNumpyArrayAlmostEqual
    np.testing.assert_array_almost_equal(first, second, decimal)
  File "C:\Users\tpc56154\miniforge3\envs\cil\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tpc56154\miniforge3\envs\cil\Lib\site-packages\numpy\testing\_private\utils.py", line 1034, in assert_array_almost_equal
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
  File "C:\Users\tpc56154\miniforge3\envs\cil\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tpc56154\miniforge3\envs\cil\Lib\site-packages\numpy\testing\_private\utils.py", line 797, in assert_array_compare
    raise AssertionError(msg)
AssertionError:
Arrays are not almost equal to 2 decimals

Mismatched elements: 10 / 10 (100%)
Max absolute difference: 0.04203627
Max relative difference: 0.2293641
 x: array([-0.23, -0.26,  0.51,  0.24,  0.5 , -0.51,  0.2 ,  0.39, -0.61,
        0.6 ], dtype=float32)
 y: array([-0.18, -0.24,  0.54,  0.27,  0.52, -0.48,  0.23,  0.43, -0.58,
        0.62], dtype=float32)

----------------------------------------------------------------------
Ran 950 tests in 84.803s

FAILED (failures=1, errors=1, skipped=251)
(cil)

gfardell avatar Mar 19 '25 17:03 gfardell

cil_demos environnment & tests on windows.

----------------------------------------------------------------------
TEST SYSTEM CONFIGURATION
CIL version:  24.3.0
{'has_astra': True,
 'has_ccpi_regularisation': True,
 'has_cvxpy': False,
 'has_ipp': True,
 'has_numba': True,
 'has_nvidia': True,
 'has_tigre': True,
 'has_tomophantom': True}
----------------------------------------------------------------------

======================================================================
FAIL: test_bb_converge (test_stepsizes.TestStepSizeBB.test_bb_converge)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\tpc56154\GitHub\CIL\Wrappers\Python\test\test_stepsizes.py", line 303, in test_bb_converge
    self.assertNumpyArrayAlmostEqual(alg.x.as_array(), alg_true.x.as_array(), decimal=2)
  File "C:\Users\tpc56154\GitHub\CIL\Wrappers\Python\test\testclass.py", line 60, in assertNumpyArrayAlmostEqual
    np.testing.assert_array_almost_equal(first, second, decimal)
  File "C:\Users\tpc56154\miniforge3\envs\cil_demos\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tpc56154\miniforge3\envs\cil_demos\Lib\site-packages\numpy\testing\_private\utils.py", line 1034, in assert_array_almost_equal
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
  File "C:\Users\tpc56154\miniforge3\envs\cil_demos\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tpc56154\miniforge3\envs\cil_demos\Lib\site-packages\numpy\testing\_private\utils.py", line 797, in assert_array_compare
    raise AssertionError(msg)
AssertionError:
Arrays are not almost equal to 2 decimals

Mismatched elements: 10 / 10 (100%)
Max absolute difference: 0.04203627
Max relative difference: 0.2293641
 x: array([-0.23, -0.26,  0.51,  0.24,  0.5 , -0.51,  0.2 ,  0.39, -0.61,
        0.6 ], dtype=float32)
 y: array([-0.18, -0.24,  0.54,  0.27,  0.52, -0.48,  0.23,  0.43, -0.58,
        0.62], dtype=float32)

----------------------------------------------------------------------
Ran 981 tests in 151.968s

FAILED (failures=1, skipped=54)

gfardell avatar Mar 19 '25 17:03 gfardell

cil_test env & windows

----------------------------------------------------------------------
TEST SYSTEM CONFIGURATION
CIL version:  24.3.0
{'has_astra': True,
 'has_ccpi_regularisation': True,
 'has_cvxpy': True,
 'has_ipp': True,
 'has_numba': True,
 'has_nvidia': True,
 'has_tigre': True,
 'has_tomophantom': True}
----------------------------------------------------------------------

======================================================================
FAIL: test_bb_converge (test_stepsizes.TestStepSizeBB.test_bb_converge)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\tpc56154\GitHub\CIL\Wrappers\Python\test\test_stepsizes.py", line 303, in test_bb_converge
    self.assertNumpyArrayAlmostEqual(alg.x.as_array(), alg_true.x.as_array(), decimal=2)
  File "C:\Users\tpc56154\GitHub\CIL\Wrappers\Python\test\testclass.py", line 60, in assertNumpyArrayAlmostEqual
    np.testing.assert_array_almost_equal(first, second, decimal)
  File "C:\Users\tpc56154\miniforge3\envs\cil_test\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tpc56154\miniforge3\envs\cil_test\Lib\site-packages\numpy\testing\_private\utils.py", line 1034, in assert_array_almost_equal
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
  File "C:\Users\tpc56154\miniforge3\envs\cil_test\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\tpc56154\miniforge3\envs\cil_test\Lib\site-packages\numpy\testing\_private\utils.py", line 797, in assert_array_compare
    raise AssertionError(msg)
AssertionError:
Arrays are not almost equal to 2 decimals

Mismatched elements: 10 / 10 (100%)
Max absolute difference: 0.04203627
Max relative difference: 0.2293641
 x: array([-0.23, -0.26,  0.51,  0.24,  0.5 , -0.51,  0.2 ,  0.39, -0.61,
        0.6 ], dtype=float32)
 y: array([-0.18, -0.24,  0.54,  0.27,  0.52, -0.48,  0.23,  0.43, -0.58,
        0.62], dtype=float32)

----------------------------------------------------------------------
Ran 981 tests in 149.922s

FAILED (failures=1, skipped=40)

gfardell avatar Mar 19 '25 17:03 gfardell

alternatively, shouldn't we add these files to the CIL-Demos repo directly instead of here?

Then CIL's CI could do

pytest .

git clone https://github.com/TomographicImaging/CIL-Demos
sed -ri '/- cil($|\s|[<>=])/d' ./CIL-Demos/environment.yml # remove CIL
conda install --file ./CIL-Demos/environment.yml

pytest --nbval ./CIL-Demos/.../some_notebook.ipynb

casperdcl avatar Apr 24 '25 10:04 casperdcl

Moved the environment files to a separate repo https://github.com/TomographicImaging/Build-scripts/pull/1] This PR just has checks for skimage before running tests

hrobarts avatar May 27 '25 07:05 hrobarts

Tested skipping skimage using:

  • Cil_env

    • On linux: Ran 1003 tests in 115.496s OK (skipped=283) - skipped skimage and other stuff
    • On windows: Ran 1003 tests in 169.757s OK (skipped=283) 0 skipped skimage and other stuff
  • Cil_demos_env

    • On linux: Ran 1003 tests in 238.524s OK (skipped=55) - skipped SIRF and CVXpy
    • On windows: Ran 1003 tests in 298.059s OK (skipped=55) - skipped SIRF and CVXpy
  • Cil_test_env

    • On linux: Ran 1003 tests in 229.406s OK (skipped=40) - skipped SIRF
    • On windows:

hrobarts avatar Jun 10 '25 12:06 hrobarts