Skip to content

Commit 9e23bcc

Browse files
authored
Merge pull request #65 from tiqi-group/fix/no-tiqi-zedboard
Make ICON runnable without tiqi-zedboard
2 parents b7dfc6a + 10c135c commit 9e23bcc

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/icon/server/hardware_processing/hardware_controller.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import logging
22

3-
import tiqi_zedboard.zedboard # type: ignore
3+
try:
4+
import tiqi_zedboard.zedboard # type: ignore
5+
HAS_TIQI_ZEDBOARD = True
6+
except ImportError:
7+
HAS_TIQI_ZEDBOARD = False
48

59
from icon.config.config import get_config
610
from icon.server.data_access.repositories.experiment_data_repository import ResultDict
@@ -21,11 +25,12 @@ def connect(self) -> None:
2125
logger.info("Connecting to the Zedboard")
2226
self._host = get_config().hardware.host
2327
self._port = get_config().hardware.port
24-
self._zedboard = tiqi_zedboard.zedboard.Zedboard(
25-
hostname=self._host, port=self._port
26-
)
27-
if not self.connected:
28-
logger.warning("Failed to connect to the Zedboard")
28+
if HAS_TIQI_ZEDBOARD:
29+
self._zedboard = tiqi_zedboard.zedboard.Zedboard(
30+
hostname=self._host, port=self._port
31+
)
32+
if not self.connected:
33+
logger.warning("Failed to connect to the Zedboard")
2934

3035
@property
3136
def connected(self) -> bool:
@@ -45,7 +50,11 @@ def run(self, *, sequence: str, number_of_shots: int) -> ResultDict:
4550
self.connect()
4651

4752
if not self.connected:
48-
raise RuntimeError("Could not connect to the Zedboard")
53+
if HAS_TIQI_ZEDBOARD:
54+
raise RuntimeError("Could not connect to the Zedboard")
55+
else:
56+
raise RuntimeError("Tiqi zedboard package is not available. "
57+
"Please use 'uv sync --all-extras' to install all dependencies")
4958

5059
self._update_zedboard_sequence(sequence=sequence)
5160
self._zedboard.sequence_JSON_parser.Parse_JSON_Header() # type: ignore

0 commit comments

Comments
 (0)