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

Commit

Permalink
Forbid import when tensorflow is not installed (#186)
Browse files Browse the repository at this point in the history
* Forbid import when tensorflow is not installed

* Update README with conda trickeries
  • Loading branch information
willGraham01 authored Jul 3, 2023
1 parent 2a42d36 commit d642e34
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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

0 comments on commit d642e34

Please sign in to comment.