Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: numpy 2.1.0+ raises 'NumPy internal error in AWS lambda #30200

@tabrezm

Description

@tabrezm

Describe the issue:

I have a simple Lambda function using pyarrow and numpy. The import call results in a call stack to arrayprint.py, which raises this exception:

NumPy internal error: unable to get format_options context variable

If I pin to a version less than 2.1.0, then I don't see this error. I'm guessing this change in 2.1.0 is the source of the regression. I don't know much about the Lambda execution environment, but I've seen issues before with running asyncio loops that required silly workarounds, so perhaps something similar is needed here.

Reproduce the code example:

import pyarrow as pa

Error message:

  import pyarrow as pa
File "/var/task/pyarrow/__init__.py", line 61, in <module>
  import pyarrow.lib as _lib
File "/var/task/numpy/__init__.py", line 679, in <module>
  _core.getlimits._register_known_types()
File "/var/task/numpy/_core/getlimits.py", line 236, in _register_known_types
  float128_ma = MachArLike(ld,
File "/var/task/numpy/_core/getlimits.py", line 57, in __init__
  self._str_eps = self._float_to_str(self.eps)
File "/var/task/numpy/_core/getlimits.py", line 121, in _float_to_str
  return self.params['fmt'] % array(_fr0(value)[0], self.ftype)
File "/var/task/numpy/_core/arrayprint.py", line 1719, in _array_str_implementation
  return _guarded_repr_or_str(np.ndarray.__getitem__(a, ()))
File "/var/task/numpy/_core/arrayprint.py", line 571, in wrapper
  return f(self, *args, **kwargs)
File "/var/task/numpy/_core/arrayprint.py", line 1701, in _guarded_repr_or_str
  return str(v)

Python and NumPy Versions:

python 3.12
numpy 2.3.4

Runtime Environment:

AWS Lambda, Python 3.12, x86_64 arch

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions