Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Forbid import when tensorflow is not installed #186

Merged
merged 2 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ pip install cellfinder-napari
N.B. To speed up cellfinder, you need CUDA & cuDNN installed. Instructions
[here](https://brainglobe.info/documentation/general/gpu.html).

#### Conda Install
`cellfinder-core` is available on `conda-forge`, however `tensorflow`, one of it's core dependencies, is not.
As a result; you _must_ manually install `tensorflow` into your environment - whether you do this before or after `conda install`ing doesn't matter.
Once you are ready, install `cellfinder-core` into the desired environment via conda;
```sh
conda install -c conda-forge cellfinder-core
```

Please bear in mind that running the `conda install` command above will exit without failing even if `tensorflow` is not present; however `tensorflow` will not be installed as part of this process, and thus `cellfinder-core` will not be usable.

### Usage
Before using cellfinder-core, it may be useful to take a look at the
[paper](https://doi.org/10.1371/journal.pcbi.1009074) which
Expand Down
12 changes: 12 additions & 0 deletions src/cellfinder_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
except PackageNotFoundError as e:
raise PackageNotFoundError("cellfinder-core package not installed") from e

# If tensorflow is not present, tools cannot be used.
# Throw an error in this case to prevent invocation of functions.
try:
TF_VERSION = version("tensorflow")
except PackageNotFoundError as e:
raise PackageNotFoundError(
f"cellfinder tools cannot be invoked without tensorflow. "
f"Please install tensorflow into your environment to use cellfinder tools. "
f"For more information, please see "
f"https://github.com/brainglobe/brainglobe-meta#readme."
) from e

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

Expand Down