From 38aa28cef13570d7d62f3939a512f6afc99eb3e3 Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Wed, 3 Jan 2024 09:31:39 +0000 Subject: [PATCH 1/3] Ship brainrender. Remove conda-checks that are currently not used, as we're not on conda --- brainglobe/__init__.py | 20 +--------- brainglobe/_conda_handles.py | 16 -------- pyproject.toml | 17 ++++---- tests/test_unit/test_tool_exposure.py | 57 --------------------------- 4 files changed, 10 insertions(+), 100 deletions(-) delete mode 100644 brainglobe/_conda_handles.py delete mode 100644 tests/test_unit/test_tool_exposure.py diff --git a/brainglobe/__init__.py b/brainglobe/__init__.py index 5e74c0c..f891be8 100644 --- a/brainglobe/__init__.py +++ b/brainglobe/__init__.py @@ -1,25 +1,7 @@ from importlib.metadata import PackageNotFoundError, version -from ._conda_handles import _CELLFINDER_INSTALLED, _MORPHAPI_INSTALLED - try: __version__ = version("brainglobe") -except PackageNotFoundError: +except PackageNotFoundError as e: # package is not installed pass - -# Expose tools under the brainglobe namespace -import bg_atlasapi -import bg_space -import brainreg -import brainglobe_segmentation - -# Expose tools that may not be present -# if a conda install was performed -if _MORPHAPI_INSTALLED: - # Import morphapi - import morphapi - -# cellfinder and associated packages -if _CELLFINDER_INSTALLED: - import cellfinder_core diff --git a/brainglobe/_conda_handles.py b/brainglobe/_conda_handles.py deleted file mode 100644 index 27fd021..0000000 --- a/brainglobe/_conda_handles.py +++ /dev/null @@ -1,16 +0,0 @@ -from importlib.metadata import PackageNotFoundError, version -from warnings import warn - -_CELLFINDER_INSTALLED = True -try: - version("cellfinder_core") -except PackageNotFoundError as e: - _CELLFINDER_INSTALLED = False - warn(f"BrainGlobe: cellfinder-core unavailable. Caught {str(e)}") - -_MORPHAPI_INSTALLED = True -try: - version("morphapi") -except PackageNotFoundError as e: - _MORPHAPI_INSTALLED = False - warn(f"BrainGlobe: morphapi unavailable. Caught {str(e)}") diff --git a/pyproject.toml b/pyproject.toml index 0c85c90..7f0a73e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,20 +20,21 @@ classifiers = [ ] dependencies = [ - "napari[all]", + "bg-atlasapi>=1.0.0", "bg-space>=0.5.0", + "brainglobe-napari-io", + "brainglobe-segmentation>=1.0.0", "brainglobe-utils", - "bg-atlasapi>=1.0.0", "brainreg[napari]>=1.0.0", - # brainglobe-napari [WIP], - "imio", + "brainrender>=2.1.0", "cellfinder-core>=0.3", - "morphapi>=0.1.3.0", - "brainglobe-napari-io", - # bg-atlasgen [LOCAL ONLY], - "brainglobe-segmentation>=1.0.0", "cellfinder-napari", "cellfinder", + "imio", + "morphapi>=0.1.3.0", + "napari[all]", + # bg-atlasgen [LOCAL ONLY], + # brainglobe-napari [WIP], ] [project.optional-dependencies] diff --git a/tests/test_unit/test_tool_exposure.py b/tests/test_unit/test_tool_exposure.py deleted file mode 100644 index 5e41f7b..0000000 --- a/tests/test_unit/test_tool_exposure.py +++ /dev/null @@ -1,57 +0,0 @@ -import inspect - -import pytest -from importlib_metadata import PackageNotFoundError - -import brainglobe as bg - -# Tools that will be exposed in the brainglobe module/namespace -EXPOSED_TOOLS = [ - "bg_atlasapi", - "bg_space", - "brainreg", - "brainglobe_segmentation", - "cellfinder_core", -] -OPTIONAL_TOOLS = ["morphapi", "cellfinder"] - - -def test_tool_exposure() -> None: - """Assert that each of the user-facing tool sub-modules can be imported.""" - - for exposed_tool in EXPOSED_TOOLS: - assert hasattr( - bg, exposed_tool - ), f"brainglobe has no (exposed) tool {exposed_tool}" - assert inspect.ismodule( - getattr(bg, exposed_tool) - ), f"brainglobe.{exposed_tool} is not a submodule" - - # Determine if optional dependencies were installed, - # and exposed if necessary - - # morphapi - should be exposed if installed - if bg._MORPHAPI_INSTALLED: - assert hasattr( - bg, "morphapi" - ), "morphapi is installed but not exposed." - assert inspect.ismodule( - bg.morphapi - ), "brainglobe.morphapi is not a module" - else: - assert not hasattr(bg, "morphapi") - - # cellfinder - should not be exposed if installed - # cellfinder_core - should be exposed if installed - if bg._CELLFINDER_INSTALLED: - assert not hasattr( - bg, "cellfinder" - ), "brainglobe.cellfinder is exposed" - assert hasattr( - bg, "cellfinder_core" - ), "brainglobe.cellfinder_core is not exposed" - else: - # cellfinder_core should be aliased to a function - # that throws an error when invoked - with pytest.raises(PackageNotFoundError): - bg.cellfinder_core() From 3d98b7ef69522c556096d89de7666314cea894ec Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Wed, 3 Jan 2024 09:34:39 +0000 Subject: [PATCH 2/3] Add brainrender-napari --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 7f0a73e..2acc2ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ dependencies = [ "brainglobe-utils", "brainreg[napari]>=1.0.0", "brainrender>=2.1.0", + "brainrender-napari", "cellfinder-core>=0.3", "cellfinder-napari", "cellfinder", From 7a21441df42ce088623c1018fa6c7f2b25fb561c Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Wed, 3 Jan 2024 09:39:27 +0000 Subject: [PATCH 3/3] Remove morphapi --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2acc2ef..f54bd78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,6 @@ dependencies = [ "cellfinder-napari", "cellfinder", "imio", - "morphapi>=0.1.3.0", "napari[all]", # bg-atlasgen [LOCAL ONLY], # brainglobe-napari [WIP],