Skip to content

Commit bbd5b4d

Browse files
Discovered NOONE had run make tests_all for years (probably not since Axel and I edited this). Marked
merge tests as deprecated for now given the API needs a serious update (updated some but not all now) This was an amazingly diplomatic comment given what I think about this... Fixed sdk tests though to work again by using non stabilizer backend
1 parent 9d8b53a commit bbd5b4d

File tree

7 files changed

+41
-51
lines changed

7 files changed

+41
-51
lines changed

tests/slow/merges/configs/Alice.cfg

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/slow/merges/configs/AliceBob.cfg

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/slow/merges/configs/AliceBobCharlie.cfg

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/slow/merges/test_merges.py

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import pytest
23
import os
34
import unittest
45
from pathlib import Path
@@ -18,6 +19,8 @@
1819
from simulaqron.local.setup import setup_local, assemble_qubit
1920
from simulaqron.network import Network
2021
from simulaqron.settings import simulaqron_settings
22+
from simulaqron.settings.network_config import NetworkConfigBuilder
23+
from simulaqron.settings.network_config import NetworkConfigBuilder
2124
from simulaqron.settings.simulaqron_config import SimBackend
2225
from simulaqron.toolbox.stabilizer_states import StabilizerState
2326
from simulaqron.reactor import reactor
@@ -148,6 +151,8 @@ def remote_receive_one_qubit(self, virtualNum, cnot_direction=0):
148151

149152

150153
# @for_all_methods()
154+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs refactoring to use NetQASM")
155+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs updating to new API")
151156
class TestMerge(unittest.TestCase):
152157
@classmethod
153158
def setUpClass(cls):
@@ -169,9 +174,9 @@ def setUpClass(cls):
169174
simulaqron_settings.network_config_file = network_def_file.name
170175
simulaqron_settings.save_to_file(simulaqron_settings_file.name)
171176
nodes = ["Alice", "Bob", "Charlie"]
172-
cls.network = Network(nodes=nodes, force=True)
177+
cls.network = Network(nodes=nodes, network_config_file=Path(network_def_file.name))
173178
cls.network.start()
174-
# cls.network = Network(nodes=nodes, force=True)
179+
# cls.network = Network(nodes=nodes, network_config_file=Path(network_def_file.name))
175180
# cls.network.start()
176181

177182
@classmethod
@@ -190,7 +195,7 @@ def tearDownClass(cls):
190195
network_settings_file.unlink()
191196

192197
@staticmethod
193-
def setup_node(name, node_code, classical_net_file, send_end):
198+
def setup_node(name, node_code, send_end):
194199
if simulaqron_settings.log_level == DEBUG:
195200
stdout_file = open(f"stdout-setup-node-{name}-{os.getpid()}.out.txt", "w")
196201
stderr_file = open(f"stderr-setup-node-{name}-{os.getpid()}.out.txt", "w")
@@ -200,11 +205,15 @@ def setup_node(name, node_code, classical_net_file, send_end):
200205
virtualFile = simulaqron_settings.network_config_file
201206

202207
# This file defines the nodes acting as servers in the classical communication network
203-
classicalFile = os.path.join(os.path.dirname(__file__), "configs", classical_net_file)
208+
classicalFile = virtualFile
204209

205210
# Read configuration files for the virtual quantum, as well as the classical network
206-
virtualNet = SocketsConfig(virtualFile)
207-
classicalNet = SocketsConfig(classicalFile)
211+
virtual_config = NetworkConfigBuilder()
212+
virtual_config.read_from_file(virtualFile)
213+
virtualNet = SocketsConfig(virtual_config)
214+
classical_config = NetworkConfigBuilder()
215+
classical_config.read_from_file(classicalFile)
216+
classicalNet = SocketsConfig(classical_config)
208217

209218
# Check if we should run a local classical server. If so, initialize the code
210219
# to handle remote connections on the classical communication network
@@ -218,12 +227,12 @@ def setup_node(name, node_code, classical_net_file, send_end):
218227
# execute the function runClientNode
219228
setup_local(name, virtualNet, classicalNet, lNode, node_code, send_end)
220229

221-
def run_test(self, classical_net_file):
230+
def run_test(self):
222231
pipe_list = []
223232
for name, node_code in zip(self.nodes, self.node_codes):
224233
recv_end, send_end = Pipe(False)
225234
p = Process(target=self.setup_node,
226-
args=[name, node_code, classical_net_file, send_end],
235+
args=[name, node_code, send_end],
227236
name=name)
228237
self.processes.append(p)
229238
pipe_list.append(recv_end)
@@ -241,6 +250,9 @@ def run_test(self, classical_net_file):
241250
self.assertTrue(all(results))
242251

243252

253+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs refactoring to use NetQASM")
254+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs refactoring to use NetQASM")
255+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs updating to new API")
244256
class TestBothLocal(TestMerge):
245257
@classmethod
246258
def setUpClass(cls):
@@ -296,9 +308,12 @@ def alice(cls, qReg, virtRoot, myName, classicalNet, send_end):
296308
reactor.stop()
297309

298310
def test(self):
299-
self.run_test("Alice.cfg")
311+
self.run_test()
300312

301313

314+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs refactoring to use NetQASM")
315+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs refactoring to use NetQASM")
316+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs updating to new API")
302317
class TestBothLocalNotSameReg(TestBothLocal):
303318
@classmethod
304319
@inlineCallbacks
@@ -349,6 +364,8 @@ def alice(cls, qReg, virtRoot, myName, classicalNet, send_end):
349364
reactor.stop()
350365

351366

367+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs refactoring to use NetQASM")
368+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs updating to new API")
352369
class TestBothRemote(TestMerge):
353370
@classmethod
354371
def setUpClass(cls):
@@ -435,9 +452,11 @@ def charlie(qReg, virtRoot, myName, classicalNet, send_end):
435452
send_end.send(True)
436453

437454
def test(self):
438-
self.run_test("AliceBobCharlie.cfg")
455+
self.run_test()
439456

440457

458+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs refactoring to use NetQASM")
459+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs updating to new API")
441460
class TestBothRemoteSameNodeDiffReg(TestMerge):
442461
@classmethod
443462
def setUpClass(cls):
@@ -501,9 +520,11 @@ def bob(qReg, virtRoot, myName, classicalNet, send_end):
501520
send_end.send(True)
502521

503522
def test(self):
504-
self.run_test("AliceBob.cfg")
523+
self.run_test()
505524

506525

526+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs refactoring to use NetQASM")
527+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs updating to new API")
507528
class TestBothRemoteSameNodeSameReg(TestBothRemoteSameNodeDiffReg):
508529
@staticmethod
509530
@inlineCallbacks
@@ -547,6 +568,8 @@ def alice(qReg, virtRoot, myName, classicalNet, send_end):
547568
reactor.stop()
548569

549570

571+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs refactoring to use NetQASM")
572+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs updating to new API")
550573
class TestRemoteAtoB(TestBothRemoteSameNodeDiffReg):
551574
@staticmethod
552575
@inlineCallbacks
@@ -579,6 +602,8 @@ def alice(qReg, virtRoot, myName, classicalNet, send_end):
579602
reactor.stop()
580603

581604

605+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs refactoring to use NetQASM")
606+
@pytest.mark.skip(reason="Uses deprecated internal APIs - needs updating to new API")
582607
class TestRemoteBtoA(TestBothRemoteSameNodeDiffReg):
583608
@staticmethod
584609
@inlineCallbacks

tests/slow/optional_noise/test_optional_noise.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from simulaqron.sdk.connection import SimulaQronConnection
1313
from netqasm.sdk import Qubit
1414
from simulaqron.network import Network
15-
from simulaqron.settings import simulaqron_settings
15+
from simulaqron.settings import simulaqron_settings, get_default_network_config_file
1616

1717

1818
def prep_z0(conn):
@@ -63,7 +63,7 @@ def setUpClass(cls):
6363
simulaqron_settings.noisy_qubits = True
6464
simulaqron_settings.t1 = 0.0001
6565

66-
cls.network = Network(nodes=["Alice"], force=True)
66+
cls.network = Network(nodes=["Alice"], network_config_file=get_default_network_config_file(use_embedded=True))
6767
cls.network.start()
6868

6969
@classmethod

tests/slow/sdk/test_single_qubit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,13 @@ class TestSingleQubitGate:
206206
@pytest.fixture
207207
def network(self):
208208
simulaqron_settings.default_settings()
209+
simulaqron_settings.sim_backend = SimBackend.PROJECTQ
209210
with NamedTemporaryFile(suffix=".json", delete_on_close=False) as net_config_file:
210211
simulaqron_settings.network_config_file = net_config_file.name
211212
network_builder = NetworkConfigBuilder()
212213
network_builder.using_default_network()
213214
network_builder.write_to_file(net_config_file.name)
214-
network = Network(nodes=["Alice"], force=True)
215+
network = Network(nodes=["Alice"], network_config_file=get_default_network_config_file(use_embedded=True))
215216
network.start()
216217
yield network
217218

tests/slow/sdk/test_two_qubit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def network(self):
194194
network_builder.using_default_network()
195195
network_builder.write_to_file(net_config_file.name)
196196
net_config_file.close()
197-
network = Network(nodes=["Alice", "Bob"], force=True)
197+
network = Network(nodes=["Alice", "Bob"], network_config_file=get_default_network_config_file(use_embedded=True))
198198
network.start(wait_until_running=True)
199199
yield network
200200

0 commit comments

Comments
 (0)