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

import blosc2 hangs on macOS -- causes problems with tiled.client.register #843

Open
edbarnard opened this issue Jan 10, 2025 · 4 comments

Comments

@edbarnard
Copy link
Contributor

edbarnard commented Jan 10, 2025

When trying to import tiled.client.register I encountered a hang up that happens when trying to import the blosc2 file format library. The import will never return. When terminated I get the following response. A subprocess call to cpu_info never returns. macOS 15.1.1 on arm64

(tiled-client) esbarnard@esbstudio ~ % python
Python 3.11.11 (main, Dec 11 2024, 10:28:39) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tiled
>>> tiled.__version__
'0.1.0b11'
>>> from tiled.client.register import register
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/tiled/client/register.py", line 12, in <module>
    from ..mimetypes import (
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/tiled/mimetypes.py", line 4, in <module>
    from .serialization.table import XLSX_MIME_TYPE
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/tiled/serialization/table.py", line 4, in <module>
    from ..media_type_registration import deserialization_registry, serialization_registry
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/tiled/media_type_registration.py", line 332, in <module>
    import blosc2
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/blosc2/__init__.py", line 191, in <module>
    cpu_info = get_cpu_info()
               ^^^^^^^^^^^^^^
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/blosc2/core.py", line 1192, in get_cpu_info
    cpu_info_dict = _get_cpu_info()
                    ^^^^^^^^^^^^^^^
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/blosc2/core.py", line 1156, in _get_cpu_info
    cpu_info = cpuinfo.get_cpu_info()
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/cpuinfo/cpuinfo.py", line 2759, in get_cpu_info
    output = get_cpu_info_json()
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/site-packages/cpuinfo/cpuinfo.py", line 2742, in get_cpu_info_json
    output = p1.communicate()[0]
             ^^^^^^^^^^^^^^^^
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/subprocess.py", line 1209, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/subprocess.py", line 2115, in _communicate
    ready = selector.select(timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/esbarnard/opt/anaconda3/envs/tiled-client/lib/python3.11/selectors.py", line 415, in select
    fd_event_list = self._selector.poll(timeout)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
@edbarnard
Copy link
Contributor Author

Blosc2 version

(tiled-client) esbarnard@esbstudio ~ % conda list blosc2
# packages in environment at /Users/esbarnard/opt/anaconda3/envs/tiled-client:
#
# Name                    Version                   Build  Channel
blosc2                    3.0.0                    pypi_0    pypi

@edbarnard edbarnard changed the title import blocs2 hangs on macOS -- causes problems with tiled.client.register import blosc2 hangs on macOS -- causes problems with tiled.client.register Jan 10, 2025
@edbarnard
Copy link
Contributor Author

edbarnard commented Jan 10, 2025

Upon more investigation this is a bug in the py-cpuinfo that fails specifically on some macs / OS versions.

tested examples:

Computer macOS python works?
M3 Macbook Air macOS 14.4 Native Python 3.12 WORKS
M3 Macbook Air macOS 15.2 Native Python 3.12 WORKS
M1 Ultra Mac Studio macOS 15.1.1 Rosetta Python 3.12 FAILS
M1 iMac macOS 14.6.1 Rosetta Python 3.12 WORKS
Intel i9 MacBook Pro macOS 15.0 Native x86 Python 3.12 WORKS

@danielballan
Copy link
Member

Thanks for the thorough investigation. As a workaround, blosc2 is an optional dependency of Tiled. If it is not installed, blosc2 compression will not be used. Try uninstalling?

if modules_available("blosc2"):
class Blosc2Decoder:
def __init__(self):
# Blosc seems to have no streaming interface.
# Accumulate response data in a cache here,
# and concatenate and decode at the end.
self._data = []
def decode(self, data: bytes) -> bytes:
self._data.append(data)
return b""
def flush(self) -> bytes:
# Hide this here to defer the numpy import that it triggers.
import blosc2
if len(self._data) == 1:
(data,) = self._data
else:
data = b"".join(self._data)
return blosc2.decompress(data)
SUPPORTED_DECODERS["blosc2"] = Blosc2Decoder

@edbarnard
Copy link
Contributor Author

edbarnard commented Jan 10, 2025

pip uninstall blosc2 does the trick for now. I'll submit a issue to Blosc2 and py-cpuinfo

Blosc2 Issue posted: Blosc/python-blosc2#356

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants