From 0405abc166672fb1b19073ac242934c3cab678d8 Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Mon, 3 Jul 2023 11:59:46 +0100 Subject: [PATCH 1/2] Forbid import when tensorflow is not installed --- src/cellfinder_core/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/cellfinder_core/__init__.py b/src/cellfinder_core/__init__.py index fa4fd04b..e0b2b8e7 100644 --- a/src/cellfinder_core/__init__.py +++ b/src/cellfinder_core/__init__.py @@ -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" From 1b16e58464ca4530e301e148dd57f298097f3ca0 Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Mon, 3 Jul 2023 12:29:36 +0100 Subject: [PATCH 2/2] Update README with conda trickeries --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 2a2a9703..2d013f55 100644 --- a/README.md +++ b/README.md @@ -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