-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Tensorflow will be an optional dependency due to conda-forge issues #27
Comments
Yeah sounds good. Presumably the pip metapackage could install |
Yeah, the plan will be pip install brainglobe to fetch Meanwhile, the conda instructions will be
But the |
Sounds good. Thanks @willGraham01! |
Having gone through With this in mind, a potential alternative approach:
Comparison
Happy to continue with the original plan, however thought I'd air the alternative now that it comes to mind. The WIP changes based on the original plan are here if you want to evaluate for yourself. |
I'm not sure what the best way to proceed is. I think two things are fairly clear:
Is it possible to do the following:
I think this is the best solution. If a user wants to use a cellfinder tool specifically, they can follow the pip instructions and it will all be fine. For newcomers to brainglobe, they can follow the conda one-liner, and this only gets complicated if, and only if, they want to use cellfinder. As an aside, the tensorflow dependency is becoming a pain for multiple reasons, I wonder if it's worth moving to torch/jax? |
The question is whether it's worth providing try:
TF_VERSION = version("tensorflow")
TF_PRESENT = True
except PackageNotFoundError as e:
TF_PRESENT = False
# helpful message about tensorflow not being there, so cellfinder is unavailable
if TF_PRESENT:
# expose cellfinder tools to the user
else:
# do nothing? Or maybe import some functions that we can alias to play the role of "cellfinder" which just throw warnings and exit when invoked and this way, we don't need to touch any code in the Only difference is in the niche case where someone My preference is slightly for the newer plan since all our changes to fix (what I perceive as) a conda problem live either on conda, or in the meta-package. As opposed to all our cellfinder packages needing large changes to accomodate conda, and even then not actually providing the functions they say they would. But I'm persuad-able either way, maybe @alessandrofelder or anyone else who've worked on |
Ah I didn't know that. Can we get the conda metapackage to ship a tensorflow-less cellfinder? I just like the idea of the metapackage shipping as much as possible and reducing the number of steps (and time) for the user to use these tools. Considering |
We can; then the next question is what do we want to allow in the event of no
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 [RELEVANT LINK TO BG-META DOCS]."
) from e The latter means we wouldn't have to guard each individual function, but it would mean our The former would mean the From the user's perspective, both approaches are the same: they get an error when they try to use |
I'd vote for the latter. |
Will do - will update the PR to be the latter.
Also I didn't realise this - I've broken that out into brainglobe/brainglobe-meta#14 |
Closing as solved in conda-forge/cellfinder-core-feedstock#14 |
See issue on
conda-forge/cellfinder-core
for context.Is your feature request related to a problem? Please describe.
Any package with a hard dependency on tensorflow cannot be installed via
conda-forge
. This primarily affects thecellfinder-core
package, but also it's dependents (cellfinder-napari
,cellfinder
, and thus the meta-package).These packages will thus be updated to make
tensorflow
an optional dependency.pip
will be able to install the optionaltensorflow
features becausetensorflow
is available frompip
, andconda
will have to make do with the "base" packages.Describe the solution you'd like
cellfinder-core
needs to be updated with an optionaltensorflow
dependency. Forbid import whentensorflow
is not installed cellfinder-core#186__init__.py
will need to check whether the tensorflow dependency is available, and set an internal flag.tensorflow
-dependent code will need to check this internal flag before running. From this, we will be able to create a complete list of allcellfinder-core
features that depend on thetensorflow
install.PyPI
. Whilst not a breaking change, the install instructions will need to be clearly updated to indicate thattensorflow
needs to be explicitly requested.cellfinder-core
will also need to be updated to be compatible with or withouttensorflow
.cellfinder-core
to have an optionaltensorflow
dependency that can be requested whenpip
-installing.cellfinder-napari
updated | Pending CI fix | Then tag new versioncellfinder
updated | Pending package update | Then tag new versionbrainglobe-meta
updatedconda-forge
recipes for all concerned packages will need to be updated.cellfinder-core
cellfinder-napari
cellfinder
(not onconda-forge
yet, and proposed to be removed so maybe un-necessary).brainglobe-meta
(in staging)Describe alternatives you've considered
See issue on
conda-forge/cellfinder-core
.Alternative is we keep things as they are on
PyPI
, and put "broken" packages onconda-forge
that require Windows users to manually installtensorflow
first.@adamltyson just to double-check this all looks good before I commit changes to multiple packages across the whole organisation.
The text was updated successfully, but these errors were encountered: