18
18
Templates ,
19
19
setup_wallet ,
20
20
)
21
+ import logging
22
+
23
+ logging .basicConfig (
24
+ format = "%(asctime)s %(message)s" ,
25
+ level = logging .DEBUG ,
26
+ )
27
+
28
+ LOCALNET_IMAGE_NAME = "ghcr.io/opentensor/subtensor-localnet:devnet-ready"
21
29
22
30
23
31
def wait_for_node_start (process , timestamp = None ):
@@ -43,7 +51,9 @@ def wait_for_node_start(process, timestamp=None):
43
51
# To prevent the buffer filling up
44
52
def read_output ():
45
53
while True :
46
- if not process .stdout .readline ():
54
+ line = process .stdout .readline ()
55
+
56
+ if not line :
47
57
break
48
58
49
59
reader_thread = threading .Thread (target = read_output , daemon = True )
@@ -132,6 +142,7 @@ def is_docker_running():
132
142
stderr = subprocess .DEVNULL ,
133
143
check = True ,
134
144
)
145
+ subprocess .run (["docker" , "pull" , LOCALNET_IMAGE_NAME ], check = True )
135
146
return True
136
147
except subprocess .CalledProcessError :
137
148
return False
@@ -141,6 +152,7 @@ def try_start_docker():
141
152
try :
142
153
subprocess .run (["open" , "-a" , "Docker" ], check = True ) # macOS
143
154
except (FileNotFoundError , subprocess .CalledProcessError ):
155
+ return True
144
156
try :
145
157
subprocess .run (["systemctl" , "start" , "docker" ], check = True ) # Linux
146
158
except (FileNotFoundError , subprocess .CalledProcessError ):
@@ -162,7 +174,6 @@ def try_start_docker():
162
174
return False
163
175
164
176
container_name = f"test_local_chain_{ str (time .time ()).replace ("." , "_" )} "
165
- image_name = "ghcr.io/opentensor/subtensor-localnet:devnet-ready"
166
177
167
178
# Command to start container
168
179
cmds = [
@@ -175,7 +186,7 @@ def try_start_docker():
175
186
"9944:9944" ,
176
187
"-p" ,
177
188
"9945:9945" ,
178
- image_name ,
189
+ LOCALNET_IMAGE_NAME ,
179
190
params ,
180
191
]
181
192
0 commit comments