@@ -98,14 +98,10 @@ def setup():
98
98
)
99
99
)
100
100
click .echo (
101
- click .style (
102
- ' git config --global user.name "Your (user)name"' , fg = "red"
103
- )
101
+ click .style (' git config --global user.name "Your (user)name"' , fg = "red" )
104
102
)
105
103
click .echo (
106
- click .style (
107
- ' git config --global user.email "Your email"' , fg = "red"
108
- )
104
+ click .style (' git config --global user.email "Your email"' , fg = "red" )
109
105
)
110
106
install_error = True
111
107
@@ -181,7 +177,9 @@ def setup():
181
177
click .style ("\t 2. Navigate to https://github.com/settings/tokens" , fg = "red" )
182
178
)
183
179
click .echo (click .style ("\t 3. Click on 'Generate new token'." , fg = "red" ))
184
- click .echo (click .style ("\t 4. Click on 'Generate new token (classic)'." , fg = "red" ))
180
+ click .echo (
181
+ click .style ("\t 4. Click on 'Generate new token (classic)'." , fg = "red" )
182
+ )
185
183
click .echo (
186
184
click .style (
187
185
"\t 5. Fill out the form to generate a new token. Ensure you select the 'repo' scope." ,
@@ -236,7 +234,10 @@ def create(agent_name):
236
234
237
235
existing_arena_files = [name .lower () for name in os .listdir ("./arena/" )]
238
236
239
- if not os .path .exists (new_agent_dir ) and not new_agent_name in existing_arena_files :
237
+ if (
238
+ not os .path .exists (new_agent_dir )
239
+ and not new_agent_name in existing_arena_files
240
+ ):
240
241
shutil .copytree ("./autogpts/forge" , new_agent_dir )
241
242
click .echo (
242
243
click .style (
@@ -271,7 +272,11 @@ def start(agent_name, no_setup):
271
272
agent_dir = os .path .join (script_dir , f"autogpts/{ agent_name } " )
272
273
run_command = os .path .join (agent_dir , "run" )
273
274
run_bench_command = os .path .join (agent_dir , "run_benchmark" )
274
- if os .path .exists (agent_dir ) and os .path .isfile (run_command ) and os .path .isfile (run_bench_command ):
275
+ if (
276
+ os .path .exists (agent_dir )
277
+ and os .path .isfile (run_command )
278
+ and os .path .isfile (run_bench_command )
279
+ ):
275
280
os .chdir (agent_dir )
276
281
if not no_setup :
277
282
click .echo (f"⌛ Running setup for agent '{ agent_name } '..." )
@@ -331,6 +336,7 @@ def stop():
331
336
except subprocess .CalledProcessError :
332
337
click .echo ("No process is running on port 8080" )
333
338
339
+
334
340
@agent .command ()
335
341
def list ():
336
342
"""List agents command"""
@@ -417,7 +423,7 @@ def benchmark_categories_list():
417
423
)
418
424
# Use it as the base for the glob pattern, excluding 'deprecated' directory
419
425
for data_file in glob .glob (glob_path , recursive = True ):
420
- if ' deprecated' not in data_file :
426
+ if " deprecated" not in data_file :
421
427
with open (data_file , "r" ) as f :
422
428
try :
423
429
data = json .load (f )
@@ -461,7 +467,7 @@ def benchmark_tests_list():
461
467
)
462
468
# Use it as the base for the glob pattern, excluding 'deprecated' directory
463
469
for data_file in glob .glob (glob_path , recursive = True ):
464
- if ' deprecated' not in data_file :
470
+ if " deprecated" not in data_file :
465
471
with open (data_file , "r" ) as f :
466
472
try :
467
473
data = json .load (f )
@@ -598,6 +604,7 @@ def benchmark_tests_details(test_name):
598
604
print (f"IOError: file could not be read: { data_file } " )
599
605
continue
600
606
607
+
601
608
@cli .group ()
602
609
def arena ():
603
610
"""Commands to enter the arena"""
@@ -760,7 +767,7 @@ def enter(agent_name, branch):
760
767
761
768
# Create a PR into the parent repository
762
769
g = Github (github_access_token )
763
- repo_name = github_repo_url .replace ("https://github.com/" , '' )
770
+ repo_name = github_repo_url .replace ("https://github.com/" , "" )
764
771
repo = g .get_repo (repo_name )
765
772
parent_repo = repo .parent
766
773
if parent_repo :
@@ -838,8 +845,8 @@ def enter(agent_name, branch):
838
845
def update (agent_name , hash , branch ):
839
846
import json
840
847
import os
841
- from datetime import datetime
842
848
import subprocess
849
+ from datetime import datetime
843
850
844
851
# Check if the agent_name.json file exists in the arena directory
845
852
agent_json_file = f"./arena/{ agent_name } .json"
@@ -898,16 +905,28 @@ def update(agent_name, hash, branch):
898
905
)
899
906
900
907
901
- def wait_until_conn_ready (port : int = 8000 ):
902
- """Polls localhost:{port} until it is available for connections"""
903
- import time
908
+ def wait_until_conn_ready (port : int = 8000 , timeout : int = 30 ):
909
+ """
910
+ Polls localhost:{port} until it is available for connections
911
+
912
+ Params:
913
+ port: The port for which to wait until it opens
914
+ timeout: Timeout in seconds; maximum amount of time to wait
915
+
916
+ Raises:
917
+ TimeoutError: If the timeout (seconds) expires before the port opens
918
+ """
904
919
import socket
920
+ import time
905
921
922
+ start = time .time ()
906
923
while True :
907
924
time .sleep (0.5 )
908
925
with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as s :
909
- if s .connect_ex ((' localhost' , port )) == 0 :
926
+ if s .connect_ex ((" localhost" , port )) == 0 :
910
927
break
928
+ if time .time () > start + timeout :
929
+ raise TimeoutError (f"Port { port } did not open within { timeout } seconds" )
911
930
912
931
913
932
if __name__ == "__main__" :
0 commit comments