Skip to content

Commit e777be7

Browse files
committed
Adapt external.py to upcoming changes in QNodeOS 2.0
1 parent 1c07023 commit e777be7

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ htmlcov/
1212
.coverage
1313
.idea/*
1414
.vscode/*
15+
16+
venv/

netqasm/sdk/external.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,39 @@
2121

2222
if is_using_hardware:
2323
try:
24-
from qnodeos.sdk.connection import (
25-
QNodeOSConnection as NetQASMConnection, # type: ignore
26-
)
27-
from qnodeos.sdk.socket import Socket # type: ignore
28-
29-
from netqasm.runtime.hardware import run_application # type: ignore
24+
from qnodeos.connection import *
25+
from qnodeos.socket import *
3026
except ModuleNotFoundError:
31-
raise ModuleNotFoundError("to use QNodeOS , `qnodeos` needs to be installed")
27+
raise ModuleNotFoundError("To use QNodeOS , `qnodeos` needs to be installed")
28+
29+
from netqasm.runtime.hardware import run_application # type: ignore
30+
31+
from abc import ABC
32+
from netqasm.sdk.classical_communication.socket import Socket as ABCSocket
33+
from netqasm.sdk.connection import BaseNetQASMConnection
34+
35+
36+
class NetQASMConnection(BaseNetQASMConnection, ABC):
37+
"""
38+
QNodeOS has dropped support for direct instantiations of `NetQASMConnection`.
39+
Use `qnodeos.connection.QNodeOSConnectionFactory` to create connections.
40+
"""
41+
pass
42+
43+
44+
class Socket(ABCSocket, ABC):
45+
"""
46+
QNodeOS has dropped support for `Socket`.
47+
Use `qnodeos.socket.[Client,Server]AppSocket` instead.
48+
"""
49+
pass
50+
51+
52+
raise DeprecationWarning(
53+
"QNodeOS has dropped support for `NetQASMConnection` and `Socket`."
54+
" Use `qnodeos.connection.QNodeOSConnectionFactory` to create connections and"
55+
" use `qnodeos.socket.[Client,Server]AppSocket` to replace `Socket`.")
56+
3257
elif simulator == Simulator.NETSQUID:
3358
try:
3459
from squidasm.nqasm.multithread import (

0 commit comments

Comments
 (0)