xarray icon indicating copy to clipboard operation
xarray copied to clipboard

Nightly Hypothesis tests failed

Open github-actions[bot] opened this issue 1 year ago • 3 comments

Workflow Run URL

Python 3.12 Test Summary
properties/test_index_manipulation.py::DatasetTest::runTest: TypeError: cannot pickle '_thread._local' object
Falsifying example:
state = DatasetStateMachine()
state.init_ds(var=Variable(data=array([0], dtype=int32), dims=['0'], attrs={}))
state.assert_invariants()
state.teardown()
Explanation:
    These lines were always and only run by failing examples:
        /home/runner/micromamba/envs/xarray-tests/lib/python3.12/dataclasses.py:1327

You can reproduce this example by temporarily adding @reproduce_failure('6.135.12', b'AABBAEEAQQFBAIEwQQAAAEEBQQAB') as a decorator on your test case

github-actions[bot] avatar Oct 30 '24 00:10 github-actions[bot]

That's from #8737 and I think the correct behavior. I don't know hypothesis so not sure what to do about this.

mathause avatar Oct 30 '24 10:10 mathause

@Zac-HD I am seeing this weird traceback locally. It appears for hypothesis >= 6.131.0. Do you know what's going on?

x = <_thread._local object at 0x149990a90>
memo = {5139024512: {'_SearchStrategy__label': 13472932985108582247, 'average_size': 2.5, 'cached_is_cacheable': True, 'cache...d', 'Lm', 'No', 'Lo', 'Lu', 'Ll')), max_size=5), 5528042048: characters(max_codepoint=383, categories=['L', 'N']), ...}
_nil = []

    def deepcopy(x, memo=None, _nil=[]):
        """Deep copy operation on arbitrary Python objects.

        See the module's __doc__ string for more info.
        """

        if memo is None:
            memo = {}

        d = id(x)
        y = memo.get(d, _nil)
        if y is not _nil:
            return y

        cls = type(x)

        copier = _deepcopy_dispatch.get(cls)
        if copier is not None:
            y = copier(x, memo)
        else:
            if issubclass(cls, type):
                y = _deepcopy_atomic(x, memo)
            else:
                copier = getattr(x, "__deepcopy__", None)
                if copier is not None:
                    y = copier(memo)
                else:
                    reductor = dispatch_table.get(cls)
                    if reductor:
                        rv = reductor(x)
                    else:
                        reductor = getattr(x, "__reduce_ex__", None)
                        if reductor is not None:
>                           rv = reductor(4)
                                 ^^^^^^^^^^^
E                           TypeError: cannot pickle '_thread._local' object
E                           Falsifying example:
E                           state = DatasetStateMachine()
E                           state.init_ds(var=Variable(data=array([0], dtype=int32), dims=['0'], attrs={}))
E                           state.assert_invariants()
E                           state.teardown()
E
E                           You can reproduce this example by temporarily adding @reproduce_failure('6.131.32', b'AABBAEEAQQFBAIEwQQAAAEEBQQAB') as a decorator on your test case

/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:151: TypeError
------------------------------------------------------------------------------------- Hypothesis --------------------------------------------------------------------------------------
Trying example:
obj = <[TypeError("cannot pickle '_thread._local' object") raised in repr()] Rule object at 0x1497f6ea0>

    def asdict(obj, *, dict_factory=dict):
        """Return the fields of a dataclass instance as a new dictionary mapping
        field names to field values.

        Example usage::

          @dataclass
          class C:
              x: int
              y: int

          c = C(1, 2)
          assert asdict(c) == {'x': 1, 'y': 2}

        If given, 'dict_factory' will be used instead of built-in dict.
        The function applies recursively to field values that are
        dataclass instances. This will also look into built-in containers:
        tuples, lists, and dicts. Other objects are copied with 'copy.deepcopy()'.
        """
        if not _is_dataclass_instance(obj):
            raise TypeError("asdict() should be called on dataclass instances")
>       return _asdict_inner(obj, dict_factory)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/dataclasses.py:1329:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/dataclasses.py:1339: in _asdict_inner
    f.name: _asdict_inner(getattr(obj, f.name), dict)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/dataclasses.py:1382: in _asdict_inner
    return type(obj)((_asdict_inner(k, dict_factory),
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/dataclasses.py:1383: in <genexpr>
    _asdict_inner(v, dict_factory))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/dataclasses.py:1386: in _asdict_inner
    return copy.deepcopy(obj)
           ^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:162: in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:259: in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:136: in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:221: in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:162: in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:259: in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:136: in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:221: in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:136: in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:221: in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:162: in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:259: in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:136: in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:221: in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:162: in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:259: in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:136: in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:221: in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

x = <_thread._local object at 0x149990a90>
memo = {5139024512: {'_SearchStrategy__label': 13472932985108582247, 'average_size': 2.5, 'cached_is_cacheable': True, 'cache...d', 'Lm', 'No', 'Lo', 'Lu', 'Ll')), max_size=5), 5528042048: characters(max_codepoint=383, categories=['L', 'N']), ...}
_nil = []

    def deepcopy(x, memo=None, _nil=[]):
        """Deep copy operation on arbitrary Python objects.

        See the module's __doc__ string for more info.
        """

        if memo is None:
            memo = {}

        d = id(x)
        y = memo.get(d, _nil)
        if y is not _nil:
            return y

        cls = type(x)

        copier = _deepcopy_dispatch.get(cls)
        if copier is not None:
            y = copier(x, memo)
        else:
            if issubclass(cls, type):
                y = _deepcopy_atomic(x, memo)
            else:
                copier = getattr(x, "__deepcopy__", None)
                if copier is not None:
                    y = copier(memo)
                else:
                    reductor = dispatch_table.get(cls)
                    if reductor:
                        rv = reductor(x)
                    else:
                        reductor = getattr(x, "__reduce_ex__", None)
                        if reductor is not None:
>                           rv = reductor(4)
                                 ^^^^^^^^^^^
E                           TypeError: cannot pickle '_thread._local' object

/Users/deepak/miniforge3/envs/xarray-tests/lib/python3.12/copy.py:151: TypeError

dcherian avatar Jun 18 '25 01:06 dcherian

not immediately - mind opening a Hypothesis issue with a repro?

Zac-HD avatar Jun 18 '25 16:06 Zac-HD