Skip to content

TST: astropy/time/tests/test_methods.py might trigger race condition in parallel job #11966

Closed

Description

@pllim

As @WilliamJamieson noticed in #11930 , the way that astropy/time/tests/test_methods.py uses its fixture and global variable might trigger race condition in parallel job under very specific circumstances. A refactor might be necessary, Looks like @taldcroft added this in #6028 .

Example log: https://github.com/astropy/astropy/pull/11930/checks?check_run_id=3128121184

_______________ ERROR at setup of TestShapeFunctions.test_fliplr _______________
[gw0] linux -- Python 3.7.11 /__w/astropy/astropy/.tox/py37-test/bin/python

cls = <class 'astropy.time.tests.test_methods.TestShapeFunctions'>

    def setup_class(cls):
        mjd = np.arange(50000, 50010)
        frac = np.arange(0., 0.999, 0.2)
>       if use_masked_data:
E       NameError: name 'use_masked_data' is not defined

../../.tox/py37-test/lib/python3.7/site-packages/astropy/time/tests/test_methods.py:38: NameError
_______________ ERROR at setup of TestShapeFunctions.test_rot90 ________________
[gw0] linux -- Python 3.7.11 /__w/astropy/astropy/.tox/py37-test/bin/python

cls = <class 'astropy.time.tests.test_methods.TestShapeFunctions'>

    def setup_class(cls):
        mjd = np.arange(50000, 50010)
        frac = np.arange(0., 0.999, 0.2)
>       if use_masked_data:
E       NameError: name 'use_masked_data' is not defined

../../.tox/py37-test/lib/python3.7/site-packages/astropy/time/tests/test_methods.py:38: NameError
________________ ERROR at setup of TestShapeFunctions.test_roll ________________
[gw0] linux -- Python 3.7.11 /__w/astropy/astropy/.tox/py37-test/bin/python

cls = <class 'astropy.time.tests.test_methods.TestShapeFunctions'>

    def setup_class(cls):
        mjd = np.arange(50000, 50010)
        frac = np.arange(0., 0.999, 0.2)
>       if use_masked_data:
E       NameError: name 'use_masked_data' is not defined

../../.tox/py37-test/lib/python3.7/site-packages/astropy/time/tests/test_methods.py:38: NameError
_______________ ERROR at setup of TestShapeFunctions.test_delete _______________
[gw0] linux -- Python 3.7.11 /__w/astropy/astropy/.tox/py37-test/bin/python

cls = <class 'astropy.time.tests.test_methods.TestShapeFunctions'>

    def setup_class(cls):
        mjd = np.arange(50000, 50010)
        frac = np.arange(0., 0.999, 0.2)
>       if use_masked_data:
E       NameError: name 'use_masked_data' is not defined

../../.tox/py37-test/lib/python3.7/site-packages/astropy/time/tests/test_methods.py:38: NameError

@pytest.fixture(scope="module", params=[True, False])
def masked(request):
# Could not figure out a better way to parametrize the setup method
global use_masked_data
use_masked_data = request.param
yield use_masked_data

if use_masked_data:

Activity

  1. pllim commented on Jul 22, 2021

    @pllim
    MemberAuthor

    @WilliamJamieson was able to consistently reproduce this problem using a command similar to this locally from the affected PR's branch, though the PR changes have nothing to do with astropy.time:

    run: /opt/python/cp37-cp37m/bin/python -m tox -e py37-test -- -n=4 --durations=50

    As he reported as well, the following did not trigger the race condition:

    • pytest -n=4 --durations=50
    • python -m tox -e py37-test -- --durations=50
  2. WilliamJamieson commented on Jul 26, 2021

    @WilliamJamieson
    Contributor

    I'll take a look at this, since its blocking my PR.

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions