tqsd / QuNetSim

A quantum network simulation framework.
https://tqsd.github.io/QuNetSim/
MIT License
118 stars 52 forks source link

Changing the default backend #23

Closed stephendiadamo closed 4 years ago

stephendiadamo commented 4 years ago

@benjione In host.py I removed the exception since it fires when await_ack = False but it doesn't break the tests so I think the except isn't needed. What do you think?

stephendiadamo commented 4 years ago

This is somehow causing problems... Somehow when EQSN is imported it causes this error when it's not used... It might be an issue with SimulaQron clashing with EQSN for "multiprocessing manager".

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 114, in _main
    prepare(preparation_data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 225, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 277, in _fixup_main_from_path
    run_name="__mp_main__")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 263, in run_path
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 105, in spawn_main
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 105, in spawn_main
    pkg_name=pkg_name, script_name=fname)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 96, in _run_module_code
    exitcode = _main(fd)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 114, in _main
    mod_name, mod_spec, pkg_name, script_name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/stephendiadamo/Projects/simulation_quantum/perf.py", line 1, in <module>
    from components.host import Host
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/host.py", line 2, in <module>
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 105, in spawn_main
    from components import protocols
    prepare(preparation_data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 225, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 277, in _fixup_main_from_path
    run_name="__mp_main__")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/stephendiadamo/Projects/simulation_quantum/perf.py", line 1, in <module>
    from components.host import Host
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/host.py", line 2, in <module>
    from components import protocols
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/protocols.py", line 6, in <module>
    exitcode = _main(fd)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 114, in _main
    prepare(preparation_data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 225, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 277, in _fixup_main_from_path
    run_name="__mp_main__")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/stephendiadamo/Projects/simulation_quantum/perf.py", line 1, in <module>
    from components.host import Host
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/host.py", line 2, in <module>
    from components import protocols
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/protocols.py", line 6, in <module>
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/protocols.py", line 6, in <module>
    exitcode = _main(fd)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 114, in _main
    prepare(preparation_data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 225, in prepare
    from components.network import Network
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/network.py", line 16, in <module>
    from components.network import Network
    from components.network import Network
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/network.py", line 16, in <module>
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/network.py", line 16, in <module>
    from backends.eqsn_backend import EQSNBackend
    from backends.eqsn_backend import EQSNBackend
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/backends/eqsn_backend.py", line 1, in <module>
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/backends/eqsn_backend.py", line 1, in <module>
    _fixup_main_from_path(data['init_main_from_path'])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 277, in _fixup_main_from_path
    from backends.eqsn_backend import EQSNBackend
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/backends/eqsn_backend.py", line 1, in <module>
    run_name="__mp_main__")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 263, in run_path
    import eqsn
    pkg_name=pkg_name, script_name=fname)
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/eqsn/__init__.py", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/stephendiadamo/Projects/simulation_quantum/perf.py", line 1, in <module>
    import eqsn
    from components.host import Host
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/host.py", line 2, in <module>
    import eqsn
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/eqsn/__init__.py", line 1, in <module>
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/eqsn/__init__.py", line 1, in <module>
    from components import protocols
    from eqsn.gates import X_gate, Y_gate, Z_gate, cnot_gate, cphase_gate, H_gate, \
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/eqsn/gates.py", line 7, in <module>
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/protocols.py", line 6, in <module>
    from eqsn.gates import X_gate, Y_gate, Z_gate, cnot_gate, cphase_gate, H_gate, \
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/eqsn/gates.py", line 7, in <module>
    from eqsn.gates import X_gate, Y_gate, Z_gate, cnot_gate, cphase_gate, H_gate, \
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/eqsn/gates.py", line 7, in <module>
    manager = multiprocessing.Manager()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/context.py", line 56, in Manager
    from components.network import Network
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/network.py", line 16, in <module>
    from backends.eqsn_backend import EQSNBackend
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/backends/eqsn_backend.py", line 1, in <module>
    import eqsn
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/eqsn/__init__.py", line 1, in <module>
    manager = multiprocessing.Manager()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/context.py", line 56, in Manager
    manager = multiprocessing.Manager()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/context.py", line 56, in Manager
    m.start()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/managers.py", line 513, in start
    from eqsn.gates import X_gate, Y_gate, Z_gate, cnot_gate, cphase_gate, H_gate, \
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/eqsn/gates.py", line 7, in <module>
    manager = multiprocessing.Manager()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/context.py", line 56, in Manager
    m.start()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/managers.py", line 513, in start
    m.start()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/managers.py", line 513, in start
    self._process.start()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/process.py", line 105, in start
    m.start()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/managers.py", line 513, in start
    self._process.start()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/process.py", line 105, in start
    self._process.start()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/process.py", line 105, in start
    self._popen = self._Popen(self)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    self._popen = self._Popen(self)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_fork.py", line 26, in __init__
    self._process.start()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/process.py", line 105, in start
    self._popen = self._Popen(self)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_fork.py", line 26, in __init__
    self._launch(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
    self._popen = self._Popen(self)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_fork.py", line 26, in __init__
    self._launch(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
    super().__init__(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_fork.py", line 26, in __init__
    self._launch(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to     self._launch(process_obj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        Theuse the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
 "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
^CTraceback (most recent call last):
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/cqc/pythonLib.py", line 322, in __init__
    self._s.connect(addr[4])
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "perf.py", line 142, in <module>
    main()
  File "perf.py", line 100, in main
    network.start(nodes, backend)
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/components/network.py", line 630, in start
    self._backend.start(nodes=nodes)
  File "/Users/stephendiadamo/Projects/simulation_quantum/quantum_simulations/backends/cqc_backend.py", line 91, in start
    CQCBackend.backend_network.start()
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/simulaqron/network.py", line 175, in start
    if self.running:
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/simulaqron/network.py", line 129, in running
    cqc = CQCConnection(node, retry_connection=False, network_name=self.name)
  File "/Users/stephendiadamo/Projects/simulation_quantum/venv/lib/python3.6/site-packages/cqc/pythonLib.py", line 326, in __init__
    time.sleep(self._conn_retry_time)
KeyboardInterrupt
benjione commented 4 years ago

The bug is in EQSN, I am just fixing it and pushing a new version to pip, then it should work.

benjione commented 4 years ago

This should fix the bug.

benjione commented 4 years ago

Updated to the new version of EQSN and updated two tests. However, Nose 2 is not running throughon my computer, but executing the test outside of nose2 works for me (test_epr, single hop).