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

Fix failing unit-test test_wsireader #7905

Merged
merged 2 commits into from
Jul 14, 2024

Conversation

hjmjohnson
Copy link
Contributor

@hjmjohnson hjmjohnson commented Jul 8, 2024

Conversion of units when the unit if '' caused the test to fail.

pytest -k tiff

FAILED tests/test_wsireader.py::TestTiffFile::test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff - ValueError: Currently, it only supports length conversion but `` is given.

FAILED tests/test_wsireader.py::TestTiffFile::test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff - AttributeError: 'ConvertUnits' object has no attribute 'conversion_factor'

Description

Fixes a failing test.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.

@hjmjohnson hjmjohnson force-pushed the failing-monai-test branch 2 times, most recently from 4954c1b to 24c0c42 Compare July 8, 2024 18:46
@KumoLiu
Copy link
Contributor

KumoLiu commented Jul 9, 2024

Hi @hjmjohnson, thanks for the PR, could you please show more details when will the test failed such a small piece of code and also include the test case in the unittests? Thanks!

@KumoLiu KumoLiu requested review from drbeh, ericspod and Nic-Ma July 9, 2024 02:32
@hjmjohnson
Copy link
Contributor Author

Hi @hjmjohnson, thanks for the PR, could you please show more details when will the test failed such a small piece of code and also include the test case in the unittests? Thanks!

This is the failing unit test output from the original code:

FAILED tests/test_wsireader.py::TestTiffFile::test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff - ValueError: Currently, it only supports length conversion but `` is given.

FAILED tests/test_wsireader.py::TestTiffFile::test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff - AttributeError: 'ConvertUnits' object has no attribute 'conversion_factor'

I am trying to get full passing of all the monai tests on my computer, and these are the failures I came across.

Conversion of units when the unit if '' caused the test to fail.

FAILED tests/test_wsireader.py::TestTiffFile::test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff - ValueError: Currently, it only supports length conversion but `` is given.

FAILED tests/test_wsireader.py::TestTiffFile::test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff - AttributeError: 'ConvertUnits' object has no attribute 'conversion_factor'

Signed-off-by: Hans Johnson <hans-johnson@uiowa.edu>
@hjmjohnson
Copy link
Contributor Author

git checkout dev
git reset origin/dev --hard
pytest -k tiff
============================================================================================= FAILURES =============================================================================================
____________________________________________ TestTiffFile.test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff ____________________________________________

a = (<tests.test_wsireader.TestTiffFile testMethod=test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff>,), kw = {}

    @wraps(func)
    def standalone_func(*a, **kw):
>       return func(*(a + p.args), **p.kwargs, **kw)

.venv/lib/python3.12/site-packages/parameterized/parameterized.py:620: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_wsireader.py:593: in test_resolution_mpp
    mpp = reader.get_mpp(img_obj, level)
monai/data/wsi_reader.py:604: in get_mpp
    return self.reader.get_mpp(wsi, level)
monai/data/wsi_reader.py:1105: in get_mpp
    convert_to_micron = ConvertUnits(unit, "micrometer")
monai/utils/misc.py:808: in __init__
    self.input_unit, input_base = self._get_valid_unit_and_base(input_unit)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <monai.utils.misc.ConvertUnits object at 0x79d5f3340380>, unit = ''

    def _get_valid_unit_and_base(self, unit):
        unit = str(unit).lower()
        if unit in self.imperial_unit_of_length:
            return unit, "meter"
        for base_unit in self.base_units:
            if unit.endswith(base_unit):
                return unit, base_unit
>       raise ValueError(f"Currently, it only supports length conversion but `{unit}` is given.")
E       ValueError: Currently, it only supports length conversion but `` is given.

monai/utils/misc.py:826: ValueError

@KumoLiu
Copy link
Contributor

KumoLiu commented Jul 12, 2024

/build

@KumoLiu KumoLiu merged commit 848005d into Project-MONAI:dev Jul 14, 2024
28 checks passed
@KumoLiu KumoLiu mentioned this pull request Jul 16, 2024
7 tasks
ericspod pushed a commit that referenced this pull request Jul 16, 2024
Fixes #7918

### Description

The main issue is that enum is expressed differently between different
pythons
Related PR: #7905

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
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.

2 participants