Skip to content

3.0.0: pytest is failing in two units #110

Closed

Description

@kloczek

I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w
  • install .whl file in </install/prefix>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-threadpoolctl-3.0.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-threadpoolctl-3.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/threadpoolctl-3.0.0
plugins: mock-3.6.1, cov-3.0.0, flake8-1.0.7, isort-2.0.0
collected 59 items

tests/test_threadpoolctl.py .......s.ss.ssss.ss.sss.........F..sssssss.sssss..sss...F..                                                                              [100%]

================================================================================= FAILURES =================================================================================
_____________________________________________________________________ test_threadpool_controller_limit _____________________________________________________________________

    def test_threadpool_controller_limit():
        # Check that using the limit method of ThreadpoolController only impact its
        # library controllers.
        blas_controller = ThreadpoolController().select(user_api="blas")
        original_openmp_info = ThreadpoolController().select(user_api="openmp").info()

        with blas_controller.limit(limits=1):
            blas_controller = ThreadpoolController().select(user_api="blas")
            openmp_info = ThreadpoolController().select(user_api="openmp").info()

            assert all(
                lib_controller.num_threads == 1
                for lib_controller in blas_controller.lib_controllers
            )
            # original_blas_controller contains only blas libraries so no opemp library
            # should be impacted.
>           assert openmp_info == original_openmp_info
E           AssertionError: assert [{'filepath':...ibgomp', ...}] == [{'filepath':...ibgomp', ...}]
E             At index 0 diff: {'user_api': 'openmp', 'internal_api': 'openmp', 'prefix': 'libgomp', 'filepath': '/usr/lib64/libgomp.so.1.0.0', 'version': None, 'num_threads': 1} != {'user_api': 'openmp', 'internal_api': 'openmp', 'prefix': 'libgomp', 'filepath': '/usr/lib64/libgomp.so.1.0.0', 'version': None, 'num_threads': 12}
E             Use -v to get the full diff

tests/test_threadpoolctl.py:212: AssertionError
____________________________________________________________________________ test_architecture _____________________________________________________________________________

    def test_architecture():
        expected_openblas_architectures = (
            # XXX: add more as needed by CI or developer laptops
            "armv8",
            "Haswell",
            "SkylakeX",
            "Sandybridge",
        )
        expected_blis_architectures = (
            # XXX: add more as needed by CI or developer laptops
            "skx",
            "haswell",
        )
        for lib_info in threadpool_info():
            if lib_info["internal_api"] == "openblas":
>               assert lib_info["architecture"] in expected_openblas_architectures
E               AssertionError: assert 'Zen' in ('armv8', 'Haswell', 'SkylakeX', 'Sandybridge')

tests/test_threadpoolctl.py:565: AssertionError
========================================================================= short test summary info ==========================================================================
SKIPPED [2] tests/test_threadpoolctl.py:109: Requires libiomp runtime
SKIPPED [2] tests/test_threadpoolctl.py:109: Requires libomp runtime
SKIPPED [2] tests/test_threadpoolctl.py:109: Requires vcomp runtime
SKIPPED [2] tests/test_threadpoolctl.py:109: Requires libmkl_rt runtime
SKIPPED [2] tests/test_threadpoolctl.py:109: Requires mkl_rt runtime
SKIPPED [2] tests/test_threadpoolctl.py:109: Requires libblis runtime
SKIPPED [3] tests/test_threadpoolctl.py:253: Requires cython extensions to be compiled
SKIPPED [4] tests/test_threadpoolctl.py:271: Requires cython extensions to be compiled
SKIPPED [1] tests/test_threadpoolctl.py:352: need at least 2 shipped openblas library
SKIPPED [4] tests/test_threadpoolctl.py:362: Requires cython extensions to be compiled
SKIPPED [1] tests/test_threadpoolctl.py:450: requires MKL and the environment variable MKL_THREADING_LAYER set
SKIPPED [1] tests/test_threadpoolctl.py:465: requires BLIS and the environment variable BLIS_ENABLE_THREADING set
SKIPPED [1] tests/test_threadpoolctl.py:473: Requires cython extensions to be compiled
FAILED tests/test_threadpoolctl.py::test_threadpool_controller_limit - AssertionError: assert [{'filepath':...ibgomp', ...}] == [{'filepath':...ibgomp', ...}]
FAILED tests/test_threadpoolctl.py::test_architecture - AssertionError: assert 'Zen' in ('armv8', 'Haswell', 'SkylakeX', 'Sandybridge')
================================================================= 2 failed, 30 passed, 27 skipped in 1.09s =================================================================

Activity

  1. jeremiedbb commented on Dec 31, 2021

    @jeremiedbb
    Contributor

    Thanks for the report. The second failure is expected (I'll submit a PR for that) but the first one is really surprising: I didn't know any version of the supported blas that impact the openmp internal variables. Can you report the result of python -m threadpoolctl -i numpy scipy.linalg ?

  2. kloczek commented on Dec 31, 2021

    @kloczek
    Author

    Do you want me to test that PR? :)

    [tkloczko@ss-desktop threadpoolctl-3.0.0]$ python3 -m threadpoolctl -i numpy scipy.linalg
    WARNING: could not import scipy.linalg
    [
      {
        "user_api": "blas",
        "internal_api": "openblas",
        "prefix": "libopenblas",
        "filepath": "/usr/lib64/libopenblaso-r0.3.18.so",
        "version": "0.3.18",
        "threading_layer": "openmp",
        "architecture": "Zen",
        "num_threads": 12
      },
      {
        "user_api": "openmp",
        "internal_api": "openmp",
        "prefix": "libgomp",
        "filepath": "/usr/lib64/libgomp.so.1.0.0",
        "version": null,
        "num_threads": 12
      }
    ]

    Where I can find that scipy.linalg file?

  3. ogrisel commented on Jan 5, 2022

    @ogrisel
    Contributor

    Where I can find that scipy.linalg file?

    This is not a file, but a Python module from the scipy package. You just have to install scipy with one of the following commands depending on which distribution your are using (I assume a linux based distro in your case, no a conda based one, but I put the conda commands for completeness):

    • apt install python3-scipy (debian based distros)
    • pip install scipy (pypi.org)
    • conda install scipy (anaconda)
    • conda install -c conda-forge scipy (conda-forge)
  4. ogrisel commented on Jan 5, 2022

    @ogrisel
    Contributor

    On redhat-like systems, installing scipy can probably be achieved with dnf install but I am not sure about the package naming conventions on redhat.

  5. ogrisel commented on Jan 5, 2022

    @ogrisel
    Contributor

    Note that I reproduce the problem when running with numpy/scipy from conda-forge with openblas built with openmp...

    Also, on my macos machine I have:

        def test_architecture():
            expected_openblas_architectures = (
                # XXX: add more as needed by CI or developer laptops
                "armv8",
                "Haswell",
                "SkylakeX",
                "Sandybridge",
                "Zen",
            )
            expected_blis_architectures = (
                # XXX: add more as needed by CI or developer laptops
                "skx",
                "haswell",
            )
            for lib_info in threadpool_info():
                if lib_info["internal_api"] == "openblas":
    >               assert lib_info["architecture"] in expected_openblas_architectures
    E               AssertionError: assert 'VORTEX' in ('armv8', 'Haswell', 'SkylakeX', 'Sandybridge', 'Zen')

    I opened #113.

  6. kloczek commented on Jan 5, 2022

    @kloczek
    Author

    Where I can find that scipy.linalg file?

    This is not a file, but a Python module from the scipy package. You just have to install scipy with one of the following commands depending on which distribution your are using (I assume a linux based distro in your case, no a conda based one, but I put the conda commands for completeness):

    • apt install python3-scipy (debian based distros)
    • pip install scipy (pypi.org)
    • conda install scipy (anaconda)
    • conda install -c conda-forge scipy (conda-forge)

    It must be some kind of misunderstanding or miscommunication.
    I have no problem with installation of the scipy.
    Reported issue is not about installation scipy.
    This ticket is about scipy test suite two failing units (only two) when module installable resources are generated using pep517 based build when scipy module is not installed in its final/normally used location (which is typical when whole build and testing needs to be performed from non-root account).

    So .. please do not tell me to install Debian :P

  7. kloczek commented on Jan 5, 2022

    @kloczek
    Author

    Correction: because I'm discussing as well some issues with scipy maintainers I was almost sure that I'm commenting under the scipy ticket (which is not the case of course).
    We can postpone tis conversation until I'll try to resolve scipy build issue (I have reference to this ticket in the threadpoolctl module spec file so sooner or later I'll back to this conversation :)
    Sorry my (small) mistake :P

  8. ogrisel commented on Jan 5, 2022

    @ogrisel
    Contributor

    Sorry my (small) mistake :P

    No problem.

  9. jeremiedbb commented on Feb 7, 2022

    @jeremiedbb
    Contributor

    #114 has solved the issue described here, and we made a new release of threadpoolctl. I think this issue can be closed. Thanks @kloczek for the help.

  10. kloczek commented on Apr 11, 2022

    @kloczek
    Author

    Just tested 3.1.0 and it look way better 😄
    It is one small warning about missing setup of the asyncio_mode.

    + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-threadpoolctl-3.1.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-threadpoolctl-3.1.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
    + /usr/bin/pytest -ra
    =========================================================================== test session starts ============================================================================
    platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
    rootdir: /home/tkloczko/rpmbuild/BUILD/threadpoolctl-3.1.0
    plugins: asyncio-0.18.2, cov-3.0.0
    asyncio: mode=legacy
    collected 62 items
    
    tests/test_threadpoolctl.py ........sss.ssss.sss.ssss.............sssssss.sssss..sss......                                                                           [100%]
    
    ============================================================================= warnings summary =============================================================================
    ../../../../../usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:191
      /usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
        config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)
    
    -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
    ========================================================================= short test summary info ==========================================================================
    SKIPPED [2] tests/test_threadpoolctl.py:109: Requires vcomp runtime
    SKIPPED [2] tests/test_threadpoolctl.py:109: Requires libblas runtime
    SKIPPED [2] tests/test_threadpoolctl.py:109: Requires libmkl_rt runtime
    SKIPPED [2] tests/test_threadpoolctl.py:109: Requires libomp runtime
    SKIPPED [2] tests/test_threadpoolctl.py:109: Requires libblis runtime
    SKIPPED [2] tests/test_threadpoolctl.py:109: Requires mkl_rt runtime
    SKIPPED [2] tests/test_threadpoolctl.py:109: Requires libiomp runtime
    SKIPPED [3] tests/test_threadpoolctl.py:287: Requires cython extensions to be compiled
    SKIPPED [4] tests/test_threadpoolctl.py:305: Requires cython extensions to be compiled
    SKIPPED [1] tests/test_threadpoolctl.py:386: need at least 2 shipped openblas library
    SKIPPED [4] tests/test_threadpoolctl.py:396: Requires cython extensions to be compiled
    SKIPPED [1] tests/test_threadpoolctl.py:484: requires MKL and the environment variable MKL_THREADING_LAYER set
    SKIPPED [1] tests/test_threadpoolctl.py:499: requires BLIS and the environment variable BLIS_ENABLE_THREADING set
    SKIPPED [1] tests/test_threadpoolctl.py:507: Requires cython extensions to be compiled
    ================================================================ 33 passed, 29 skipped, 1 warning in 0.98s =================================================================

    Thank you 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions