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

BUG: Numpy New Release incompatible with Pytensor blas_headers #443

Closed
carlosagostini opened this issue Sep 18, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@carlosagostini
Copy link

carlosagostini commented Sep 18, 2023

Describe the issue:

Two days ago Numpy released a new version 1.26.0 documentation here.

The new version doesn't have anymore the attribute get_info(), which is used in the file cmodule.py (link here) on the line 2720.

Consequently, if a user tries to import pymc with Numpy > 1.25.0, he will get an error, given that these modules are used on the package.

Reproducable code example:

%pip install pytensor
%pip install numpy==1.26.0
from pytensor.tensor.blas_headers import blas_header_text, blas_header_version
import numpy as np
np.__config__.get_info("blas_opt")

Error message:

Traceback (most recent call last):
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-7295c231-b117-4c44-8446-41f1912bae58/lib/python3.9/site-packages/pytensor/configparser.py", line 201, in fetch_val_for_key
    return self._pytensor_cfg.get(section, option)
  File "/usr/lib/python3.9/configparser.py", line 781, in get
    d = self._unify_values(section, vars)
  File "/usr/lib/python3.9/configparser.py", line 1149, in _unify_values
    raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'blas'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-7295c231-b117-4c44-8446-41f1912bae58/lib/python3.9/site-packages/pytensor/configparser.py", line 317, in __get__
    val_str = cls.fetch_val_for_key(self.name, delete_key=delete_key)
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-7295c231-b117-4c44-8446-41f1912bae58/lib/python3.9/site-packages/pytensor/configparser.py", line 205, in fetch_val_for_key
    raise KeyError(key)
KeyError: 'blas__ldflags'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/databricks/python/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3378, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<command-151862714626631>", line 2, in <module>
    from pytensor.tensor.blas_headers import blas_header_text, blas_header_version
  File "/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py", line 171, in import_patch
    original_result = python_builtin_import(name, globals, locals, fromlist, level)
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-7295c231-b117-4c44-8446-41f1912bae58/lib/python3.9/site-packages/pytensor/__init__.py", line 119, in <module>
    from pytensor import scalar, tensor
  File "/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py", line 171, in import_patch
    original_result = python_builtin_import(name, globals, locals, fromlist, level)
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-7295c231-b117-4c44-8446-41f1912bae58/lib/python3.9/site-packages/pytensor/tensor/__init__.py", line 106, in <module>
    from pytensor.tensor import (  # noqa
  File "/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py", line 171, in import_patch
    original_result = python_builtin_import(name, globals, locals, fromlist, level)
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-7295c231-b117-4c44-8446-41f1912bae58/lib/python3.9/site-packages/pytensor/tensor/blas.py", line 102, in <module>
    from pytensor.tensor.blas_headers import blas_header_text, blas_header_version
  File "/databricks/python_shell/dbruntime/PythonPackageImportsInstrumentation/__init__.py", line 171, in import_patch
    original_result = python_builtin_import(name, globals, locals, fromlist, level)
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-7295c231-b117-4c44-8446-41f1912bae58/lib/python3.9/site-packages/pytensor/tensor/blas_headers.py", line 1015, in <module>
    if not config.blas__ldflags:
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-7295c231-b117-4c44-8446-41f1912bae58/lib/python3.9/site-packages/pytensor/configparser.py", line 321, in __get__
    val_str = self.default()
  File "/local_disk0/.ephemeral_nfs/envs/pythonEnv-7295c231-b117-4c44-8446-41f1912bae58/lib/python3.9/site-packages/pytensor/link/c/cmodule.py", line 2720, in default_blas_ldflags
    blas_info = np.__config__.get_info("blas_opt")
AttributeError: module 'numpy.__config__' has no attribute 'get_info'

PyTensor version information:

Python 3.9.5
Pytensor version (2.16.1)

Context for the issue:

No response

@carlosagostini carlosagostini added the bug Something isn't working label Sep 18, 2023
@twiecki
Copy link
Member

twiecki commented Sep 18, 2023

Thanks @carlosagostini, want to do a PR?

@carlosagostini
Copy link
Author

carlosagostini commented Sep 18, 2023

Sure, I'll give it a shot today or tomorrow if anyone else is already working on it 🙌🏻 @twiecki

@twiecki
Copy link
Member

twiecki commented Sep 18, 2023

Dup of #441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants