Skip to content

Commit

Permalink
shield bsb-arbor with a mocked import
Browse files Browse the repository at this point in the history
  • Loading branch information
Helveg committed Oct 31, 2023
1 parent ab8684a commit a7f3946
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bsb/simulators/arbor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
import types

# fixme: Once this adapter is moved to bsb-arbor, arbor can be a hard dependency at import
# time, and this code can be removed.
try:
import arbor
except ImportError as e:
import sys
from bsb.reporting import warn

errmsg = f"Can't use bsb-arbor: Arbor is not importable: {e}"
warn(errmsg)

class ArborMock(types.ModuleType):
class recipe:
def __getattr__(self, item):
raise AttributeError(errmsg)

def __getattr__(self, item):
raise AttributeError(errmsg)

sys.modules["arbor"] = ArborMock(name="arbor")

from bsb.simulation import SimulationBackendPlugin
from .simulation import ArborSimulation
from .adapter import ArborAdapter
Expand Down

0 comments on commit a7f3946

Please sign in to comment.