Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProjectionOperator Bug Fix (Issue #1990) #2065

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

M-A-Demir
Copy link

@M-A-Demir M-A-Demir commented Feb 6, 2025

Description

Update in response to issue #1990: ProjectionOperator device input is not case-sensitive. Added case sensitivity and unit tests for ProjectionOperator inputs. Updated environment .yml files and env creation script to include new unittest-parametrize library used in tests. Updated developer guide to include example of parametrized test usage. Added name to NOTICE.txt.

Issue: #1990

Example Usage

ProjectionOperator(ig, ag, device="GPU")
device name passed is now case insensitive

❤️ Thanks for your contribution!

M-A-Demir and others added 2 commits February 6, 2025 12:41
… not case-sensitive. Added case sensitivity and unit tests for ProjectionOperator inputs. Updated environment .yml files and env creation script to include new unittest-parametrize library used in tests. Updated developer guide to include example of parametrized test usage. Added name to NOTICE.txt.
formatting

Signed-off-by: M-A-Demir <[email protected]>
@M-A-Demir
Copy link
Author

M-A-Demir commented Feb 6, 2025

PS: In CIL/scripts/create_local_env_for_cil_development.sh, I couldn't install the pip module (unittest-parametrize) directly with the 'conda create' command , so I have changed it to use the requirements_test.yml file if $test_deps != 0.

I tried an alternative, which is to have a separate list of pip dependencies, use conda create, then activate the conda environment and perform pip install pip_dependencies, but ran into an error saying to run conda init before I can do the installations.

in GitHub Actions, Tests using unittest-parametrize produce a TypeError: TestAstraProjectors.test_ProjectionOperator_2Ddata() missing 3 required positional arguments: 'device', 'no_error_raised', and 'err_type'

Thought this may be due to an ASTRA dependency, so added @unittest.skipUnless(has_astra and has_nvidia, "Requires ASTRA GPU") to test_ProjectionOperator_3Ddata, and @unittest.skipUnless(has_astra, "Requires ASTRA") to test_ProjectionOperator_2Ddata - Only the 3D test skips, 2D test does not skip and produces same TypeError.

No issues running tests in local env:

  • python 3.10.15
  • numpy 1.24.4
  • unittest-parametrize 1.6.0

@M-A-Demir M-A-Demir linked an issue Feb 6, 2025 that may be closed by this pull request
@M-A-Demir M-A-Demir requested a review from hrobarts February 6, 2025 13:20
@M-A-Demir M-A-Demir requested a review from gfardell February 6, 2025 13:20
@M-A-Demir M-A-Demir marked this pull request as draft February 6, 2025 13:20
@M-A-Demir M-A-Demir marked this pull request as ready for review February 6, 2025 13:20
@M-A-Demir M-A-Demir self-assigned this Feb 14, 2025
@M-A-Demir
Copy link
Author

UPDATE: Fixed the TypeError issue on test - the version I pushed did not have the TestAstraProjectors class inherit from unittest_parametrize.ParametrizedTestCase, which is required to run the parametrized tests

Copy link
Member

@gfardell gfardell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a really nice addition thanks @M-A-Demir!

In addition to the small comments, could you test this on windows. @hrobarts should be able to help you out.

Wrappers/Python/test/test_PluginsAstra_Projectors.py Outdated Show resolved Hide resolved
ProjectionOperator(image_geometry=None, acquisition_geometry=None, device='gpu')

@parametrize("device, no_error_raised, err_type",
[param('cpu', True, None, id="cpu_NoError"), param('CPU', True, None, id="CPU_NoError"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if you pass "GPU" and don't have an nvidia gpu or the astra-gpu library?

I'm guessing it doesn't return very cleanly, but I wonder if it's something we could catch?

Copy link
Author

@M-A-Demir M-A-Demir Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gfardell The output if you pass "gpu"/"GPU" without the NVidia GPU is:
`Warning: Unable to get available GPU memory. Defaulting to 1GB.

Error: maxBlockDimension getDevice: CUDA error 35: CUDA driver version is insufficient for CUDA runtime version.

Warning: Error querying device

Floating point exception (core dumped)`

Which don't seem to be python-raised errors, so I'm not sure I can use that in the tests I have.
I can add some checks for NVidia GPU and astra-gpu in the ProjectionOperator class

@M-A-Demir M-A-Demir requested a review from paskino February 14, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CGLS/ProjectionOperator Stack Trace Doesn't Point To Correct Issue
2 participants