Skip to content
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
18 changes: 6 additions & 12 deletions cmac/gate_id_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,27 @@


def radar_palette_available():
"""Return True if ``radar_palette.gateid`` can be imported."""
"""Return True if CMAC's gate-ID classifier can be imported."""
try:
import radar_palette.gateid # noqa: F401
from . import radar_palette # noqa: F401
except ImportError:
return False
return True


def _import_radar_palette():
"""Import and return the ``radar_palette.gateid`` entry points.
"""Import and return CMAC's radar-palette entry points.

Raised as an ``ImportError`` with an actionable message rather than a bare
``ModuleNotFoundError`` from somewhere deep in the VAP, because selecting
this backend is a configuration choice and the fix is an install.
"""
try:
from radar_palette.gateid import entry_points, single
from .radar_palette.gateid import entry_points, single
except ImportError as err:
raise ImportError(
"gate_id_method='radar_palette' requires radar_palette.gateid, "
"which CMAC does not depend on: it is imported only when a radar "
"configuration selects this backend. The gateid module is not in "
"radar-palette's released main branch yet -- install from the "
"gateid development branch (pip install "
"'radar-palette @ git+https://github.com/scollis/radar-palette"
"@gateid'), or set gate_id_method='cmac_fuzzy' in the radar "
"configuration to use CMAC's own fuzzy classifier."
"CMAC's radar-palette gate-ID implementation could not "
"be imported. Check the CMAC installation."
) from err
return entry_points, single

Expand Down
9 changes: 9 additions & 0 deletions cmac/radar_palette/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Radar-palette components used by CMAC's gate-ID backend.

Only the gate-ID implementation is included here; the rest of radar-palette
is intentionally not part of CMAC's surface.
"""

from . import gateid

__all__ = ["gateid"]
5 changes: 5 additions & 0 deletions cmac/radar_palette/gateid/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Radar-palette gate identification implementation used by CMAC."""

from . import single

__all__ = ["single"]
Loading
Loading