2727# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2828# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
30+ import logging
3031import time
3132from typing import Callable
3233
33- from netqasm .logging .glob import get_netqasm_logger
3434from twisted .internet import error
3535from twisted .internet .defer import DeferredList
3636from twisted .internet .error import ReactorNotRunning
3939from simulaqron .general .host_config import SocketsConfig
4040from simulaqron .reactor import reactor
4141
42- _logger = get_netqasm_logger ("setup-local" )
42+ _logger = logging . getLogger ("setup-local" )
4343
4444
4545#####################################################################################################
4646#
4747# setup_local
4848#
49- # Sets up the local classical comms server (if applicable), and connects to the local virtual node
50- # and other classical communication servers.
49+ # Sets up the local classical application level comms server (if applicable), and connects to the local
50+ # virtual node and other classical communication servers.
5151
5252
5353def setup_local (myName : str , virtualNet : SocketsConfig , classicalNet : SocketsConfig ,
5454 lNode : pb .Root , func : Callable , * args , ** kwargs ):
5555 """
56- Sets up a local classical communication server (if desired according to the configuration file),
56+ Sets up a local classical applicaiton level communication server (if desired according to the configuration file),
5757 a client connection to the local virtual node quantum backend and a client connections to all other
5858 classical communication servers
5959
@@ -81,22 +81,22 @@ def setup_local(myName: str, virtualNet: SocketsConfig, classicalNet: SocketsCon
8181 if myName in classicalNet .hostDict :
8282 try :
8383 nb = classicalNet .hostDict [myName ]
84- _logger .debug ("LOCAL %s: Starting local classical communication server (%s: %s, %d)." ,
84+ _logger .debug ("SETUP_LOCAL %s: Starting local classical communication server (%s: %s, %d)." ,
8585 myName , nb .name , nb .hostname , nb .port
8686 )
8787 nb .root = lNode
8888 nb .factory = pb .PBServerFactory (nb .root )
8989 reactor .listenTCP (nb .port , nb .factory )
9090 except Exception as e :
91- _logger .error ("LOCAL %s: Cannot start classical communication servers: %s" , myName , e )
91+ _logger .error ("SETUP_LOCAL %s: Cannot start classical communication servers: %s" , myName , e )
9292 return
9393
9494 # Give the server some time to start up
9595 time .sleep (3 )
9696
9797 # Connect to the local virtual node simulating the "local" qubits
9898 node = virtualNet .hostDict [myName ]
99- _logger .debug ("LOCAL %s: Connecting to local virtual node (%s: %s, %d)." , myName , node .name , node .hostname ,
99+ _logger .debug ("SETUP_LOCAL %s: Connecting to local virtual node (%s: %s, %d)." , myName , node .name , node .hostname ,
100100 node .port )
101101 factory = pb .PBClientFactory ()
102102 reactor .connectTCP (node .hostname , node .port , factory )
@@ -107,7 +107,7 @@ def setup_local(myName: str, virtualNet: SocketsConfig, classicalNet: SocketsCon
107107 for node in classicalNet .hostDict :
108108 nb = classicalNet .hostDict [node ]
109109 if nb .name != myName :
110- _logger .debug ("LOCAL %s: Making classical connection to %s (%s: %s, %d)." , myName , nb .name , nb .name ,
110+ _logger .debug ("SETUP_LOCAL %s: Making classical connection to %s (%s: %s, %d)." , myName , nb .name , nb .name ,
111111 nb .hostname , nb .port )
112112 nb .factory = pb .PBClientFactory ()
113113 reactor .connectTCP (nb .hostname , nb .port , nb .factory )
@@ -133,7 +133,7 @@ def setup_local(myName: str, virtualNet: SocketsConfig, classicalNet: SocketsCon
133133
134134def init_register (resList : DeferredList , myName : str , virtualNet : SocketsConfig , classicalNet : SocketsConfig ,
135135 lNode : pb .Root , func : Callable , * args , ** kwargs ):
136- _logger .debug ("LOCAL %s: All connections set up." , myName )
136+ _logger .debug ("SETUP_LOCAL %s: All connections set up." , myName )
137137
138138 # Retrieve the connection to the local virtual node, if successful
139139 j = 0
@@ -142,7 +142,7 @@ def init_register(resList: DeferredList, myName: str, virtualNet: SocketsConfig,
142142 if lNode is not None :
143143 lNode .set_virtual_node (virtRoot )
144144 else :
145- _logger .error ("LOCAL %s: Connection to virtual server failed!" , myName )
145+ _logger .error ("SETUP_LOCAL %s: Connection to virtual server failed!" , myName )
146146 reactor .stop ()
147147
148148 # Retrieve connections to the classical nodes
@@ -152,9 +152,9 @@ def init_register(resList: DeferredList, myName: str, virtualNet: SocketsConfig,
152152 j = j + 1
153153 if resList [j ][0 ]:
154154 nb .root = resList [j ][1 ]
155- _logger .debug ("LOCAL %s: Connected node %s with %s" , myName , nb .name , nb .root )
155+ _logger .debug ("SETUP_LOCAL %s: Connected node %s with %s" , myName , nb .name , nb .root )
156156 else :
157- _logger .error ("LOCAL %s: Connection to %s failed!" , myName , nb .name )
157+ _logger .error ("SETUP_LOCAL %s: Connection to %s failed!" , myName , nb .name )
158158 reactor .stop ()
159159
160160 # On the local virtual node, we still want to initialize a qubit register
@@ -164,7 +164,7 @@ def init_register(resList: DeferredList, myName: str, virtualNet: SocketsConfig,
164164
165165
166166def fill_register (obj , myName , lNode , virtRoot , classicalNet , func , * args , ** kwargs ):
167- _logger .debug ("LOCAL %s: Created quantum register at virtual node." , myName )
167+ _logger .debug ("SETUP_LOCAL %s: Created quantum register at virtual node." , myName )
168168 qReg = obj
169169
170170 # If we run a server, record the handle to the local virtual register
@@ -179,7 +179,7 @@ def localError(reason):
179179 """
180180 Error handling for the connection.
181181 """
182- _logger .error ("Critical error: %s" , reason )
182+ _logger .error ("SETUP_LOCAL: Critical error: %s" , reason )
183183 try :
184184 reactor .stop ()
185185 except ReactorNotRunning :
0 commit comments