brainglobe / cellfinder-core

Standalone cellfinder cell detection algorithm
https://brainglobe.info/documentation/cellfinder/index.html
BSD 3-Clause "New" or "Revised" License
19 stars 16 forks source link

[BUG] MacOS pytest doesn't work out of the box #199

Closed alessandrofelder closed 1 year ago

alessandrofelder commented 1 year ago

Describe the bug pytest doesn't work on `pip install -e ".[dev]" in clean conda env. I get

...
exec(co, module.__dict__)
tests/tests/conftest.py:8: in <module>
    from cellfinder_core.download import models
src/cellfinder_core/__init__.py:13: in <module>
    raise PackageNotFoundError(
E   importlib.metadata.PackageNotFoundError: No package metadata was found for cellfinder tools cannot be invoked without tensorflow. Please install tensorflow into your environment to use cellfinder tools. For more information, please see https://github.com/brainglobe/brainglobe-meta#readme.

My guess is this is because our guard checks for the existence of a tensorflow package, but TensorFlow is called tensorflow-macos on Macs.

I could be missing something though. I'm surprised we haven't noticed this elsewhere 🤔

To Reproduce See above: pip install -e ".[dev]" in clean conda env on Apple Silicon.

Expected behaviour pytest should run the tests out-of-the box in a dev environment

Log file n/a

Screenshots n/a

Computer used (please complete the following information):

adamltyson commented 1 year ago

My guess is this is because our guard checks for the existence of a tensorflow package, but TensorFlow is called tensorflow-macos on Macs.

Does TensorFlow not exist on macOS? I assumed tensorflow-macos was the version compiled to use the apple silicon GPU.

I guess we need:

alessandrofelder commented 1 year ago

I should have been more precise: on Apple Silicon, tensorflow only exists from 2.13 but our current pyproject.toml requires tensorflow-macos<2.12 for Silicon chips?

On my Apple M2 at least, running pip install "tensorflow<2.12" gives

ERROR: Could not find a version that satisfies the requirement tensorflow<2.12 (from versions: 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0)
ERROR: No matching distribution found for tensorflow<2.12
alessandrofelder commented 1 year ago

Also, to be clear, tensorflow-macos install and works fine. It's just the guard that's the problem!