|
6 | 6 | from importlib.resources import files |
7 | 7 | from jinja2 import Template |
8 | 8 |
|
9 | | -from AFL.automation.APIServer.Driver import Driver # type: ignore |
10 | | -from AFL.automation.shared.utilities import mpl_plot_to_bytes, xarray_to_bytes |
| 9 | +try: |
| 10 | + from AFL.automation.APIServer.Driver import Driver # type: ignore |
| 11 | + from AFL.automation.shared.utilities import mpl_plot_to_bytes, xarray_to_bytes |
| 12 | +except ModuleNotFoundError as exc: |
| 13 | + # Allow unit tests to import this module in environments where AFL-automation |
| 14 | + # is not installed. Runtime server behavior still requires AFL-automation. |
| 15 | + if exc.name and exc.name.startswith("AFL.automation"): |
| 16 | + class Driver: # type: ignore[override] |
| 17 | + @staticmethod |
| 18 | + def unqueued(*args, **kwargs): |
| 19 | + def decorator(func): |
| 20 | + return func |
| 21 | + return decorator |
| 22 | + |
| 23 | + @staticmethod |
| 24 | + def queued(*args, **kwargs): |
| 25 | + def decorator(func): |
| 26 | + return func |
| 27 | + return decorator |
| 28 | + |
| 29 | + def __init__(self, *args, **kwargs): |
| 30 | + pass |
| 31 | + |
| 32 | + def gather_defaults(self): |
| 33 | + return getattr(self, "defaults", {}) |
| 34 | + |
| 35 | + def mpl_plot_to_bytes(*args, **kwargs): # type: ignore[no-redef] |
| 36 | + raise RuntimeError("mpl_plot_to_bytes requires AFL-automation to be installed.") |
| 37 | + |
| 38 | + def xarray_to_bytes(*args, **kwargs): # type: ignore[no-redef] |
| 39 | + raise RuntimeError("xarray_to_bytes requires AFL-automation to be installed.") |
| 40 | + else: |
| 41 | + raise |
11 | 42 | from AFL.double_agent.Pipeline import Pipeline |
12 | 43 | from AFL.double_agent.util import listify |
13 | 44 |
|
|
0 commit comments