Skip to content

Commit 99cbda0

Browse files
committed
Test Keras is present (#374)
* check if Keras present * change TF to Keras in CI * remove comment * change dependencies in pyproject.toml for Keras 3.0
1 parent 3046294 commit 99cbda0

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

.github/workflows/test_include_guard.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ jobs:
3535
import cellfinder.core
3636
import cellfinder.napari
3737
38-
- name: Uninstall tensorflow
39-
run: python -m pip uninstall -y tensorflow
38+
- name: Uninstall keras
39+
run: python -m pip uninstall -y keras
4040

4141
- name: Test (broken) import
4242
id: broken_import

cellfinder/__init__.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@
55
except PackageNotFoundError as e:
66
raise PackageNotFoundError("cellfinder package not installed") from e
77

8-
# If tensorflow is not present, tools cannot be used.
8+
# If Keras is not present with a backend, tools cannot be used.
99
# Throw an error in this case to prevent invocation of functions.
1010
try:
11-
TF_VERSION = version("tensorflow")
11+
KERAS_VERSION = version("keras")
1212
except PackageNotFoundError as e:
13-
try:
14-
TF_VERSION = version("tensorflow-macos")
15-
except PackageNotFoundError as e:
16-
raise PackageNotFoundError(
17-
f"cellfinder tools cannot be invoked without tensorflow. "
18-
f"Please install tensorflow into your environment to use cellfinder tools. "
19-
f"For more information, please see "
20-
f"https://github.com/brainglobe/brainglobe-meta#readme."
21-
) from e
13+
raise PackageNotFoundError(
14+
f"cellfinder tools cannot be invoked without Keras. "
15+
f"Please install tensorflow into your environment to use cellfinder tools. "
16+
f"For more information, please see "
17+
f"https://github.com/brainglobe/brainglobe-meta#readme."
18+
) from e
2219

2320
__author__ = "Adam Tyson, Christian Niedworok, Charly Rousseau"
2421
__license__ = "BSD-3-Clause"

pyproject.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ dependencies = [
2929
"numpy",
3030
"scikit-image",
3131
"scikit-learn",
32-
# See https://github.com/brainglobe/cellfinder-core/issues/103 for < 2.12.0 pin
33-
"tensorflow-macos>=2.5.0,<2.12.0; platform_system=='Darwin' and platform_machine=='arm64'",
34-
"tensorflow>=2.5.0,<2.12.0; platform_system!='Darwin' or platform_machine!='arm64'",
32+
"keras",
33+
"tf-nightly==2.16.0.dev20240101", # pinning to same TF as Keras 3.0
3534
"tifffile",
3635
"tqdm",
3736
]

0 commit comments

Comments
 (0)