@@ -729,35 +729,34 @@ def get_sha(branch, repo_url):
729729 return "" , ""
730730
731731
732- def get_net (commit_sha , repo_url ):
733- """Get the net from evaluate.h or ucioption.cpp in the repo"""
732+ def get_nets (commit_sha , repo_url ):
733+ """Get the nets from evaluate.h or ucioption.cpp in the repo"""
734734 api_url = repo_url .replace (
735735 "https://github.com" , "https://raw.githubusercontent.com"
736736 )
737737 try :
738- net = None
738+ nets = []
739+ pattern = re .compile ("nn-[a-f0-9]{12}.nnue" )
739740
740741 url1 = api_url + "/" + commit_sha + "/src/evaluate.h"
741742 options = requests .get (url1 ).content .decode ("utf-8" )
742743 for line in options .splitlines ():
743744 if "EvalFileDefaultName" in line and "define" in line :
744- p = re .compile ("nn-[a-z0-9]{12}.nnue" )
745- m = p .search (line )
745+ m = pattern .search (line )
746746 if m :
747- net = m .group (0 )
747+ nets . append ( m .group (0 ) )
748748
749- if net :
750- return net
749+ if nets :
750+ return nets
751751
752752 url2 = api_url + "/" + commit_sha + "/src/ucioption.cpp"
753753 options = requests .get (url2 ).content .decode ("utf-8" )
754754 for line in options .splitlines ():
755755 if "EvalFile" in line and "Option" in line :
756- p = re .compile ("nn-[a-z0-9]{12}.nnue" )
757- m = p .search (line )
756+ m = pattern .search (line )
758757 if m :
759- net = m .group (0 )
760- return net
758+ nets . append ( m .group (0 ) )
759+ return nets
761760 except :
762761 raise Exception ("Unable to access developer repository: " + api_url )
763762
@@ -919,19 +918,23 @@ def strip_message(m):
919918 )
920919 data ["base_same_as_master" ] = master_diff .text == ""
921920
922- # Test existence of net
923- new_net = get_net (data ["resolved_new" ], data ["tests_repo" ])
924- if new_net :
925- if not request .rundb .get_nn (new_net ):
926- raise Exception (
927- "The net {}, used by {}, is not "
928- "known to Fishtest. Please upload it to: "
929- "{}/upload." .format (new_net , data ["new_tag" ], request .host_url )
921+ # Store nets info
922+ data ["base_nets" ] = get_nets (data ["resolved_base" ], data ["tests_repo" ])
923+ data ["new_nets" ] = get_nets (data ["resolved_new" ], data ["tests_repo" ])
924+
925+ # Test existence of nets
926+ missing_nets = []
927+ for net_name in set (data ["base_nets" ]) | set (data ["new_nets" ]):
928+ net = request .rundb .get_nn (net_name )
929+ if net is None :
930+ missing_nets .append (net_name )
931+ if missing_nets :
932+ raise Exception (
933+ "Missing net(s). Please upload to: {} the following net(s): {}" .format (
934+ request .host_url ,
935+ ", " .join (missing_nets ),
930936 )
931-
932- # Store net info
933- data ["new_net" ] = new_net
934- data ["base_net" ] = get_net (data ["resolved_base" ], data ["tests_repo" ])
937+ )
935938
936939 # Integer parameters
937940 data ["threads" ] = int (request .POST ["threads" ])
@@ -1003,25 +1006,32 @@ def del_tasks(run):
10031006def update_nets (request , run ):
10041007 run_id = str (run ["_id" ])
10051008 data = run ["args" ]
1009+ base_nets , new_nets , missing_nets = [], [], []
1010+ for net_name in set (data ["base_nets" ]) | set (data ["new_nets" ]):
1011+ net = request .rundb .get_nn (net_name )
1012+ if net is None :
1013+ # This should never happen
1014+ missing_nets .append (net_name )
1015+ else :
1016+ if net_name in data ["base_nets" ]:
1017+ base_nets .append (net )
1018+ if net_name in data ["new_nets" ]:
1019+ new_nets .append (net )
1020+ if missing_nets :
1021+ raise Exception (
1022+ "Missing net(s). Please upload to {} the following net(s): {}" .format (
1023+ request .host_url ,
1024+ ", " .join (missing_nets ),
1025+ )
1026+ )
1027+
10061028 if run ["base_same_as_master" ]:
1007- base_net = data ["base_net" ]
1008- if base_net :
1009- net = request .rundb .get_nn (base_net )
1010- if not net :
1011- # Should never happen:
1012- raise Exception (
1013- "The net {}, used by {}, is not "
1014- "known to Fishtest. Please upload it to: "
1015- "{}/upload." .format (base_net , data ["base_tag" ], request .host_url )
1016- )
1029+ for net in base_nets :
10171030 if "is_master" not in net :
10181031 net ["is_master" ] = True
10191032 request .rundb .update_nn (net )
1020- new_net = data ["new_net" ]
1021- if new_net :
1022- net = request .rundb .get_nn (new_net )
1023- if not net :
1024- return
1033+
1034+ for net in new_nets :
10251035 if "first_test" not in net :
10261036 net ["first_test" ] = {"id" : run_id , "date" : datetime .now (timezone .utc )}
10271037 net ["last_test" ] = {"id" : run_id , "date" : datetime .now (timezone .utc )}
@@ -1228,7 +1238,10 @@ def tests_approve(request):
12281238 if run is None :
12291239 request .session .flash (message , "error" )
12301240 else :
1231- update_nets (request , run )
1241+ try :
1242+ update_nets (request , run )
1243+ except Exception as e :
1244+ request .session .flash (str (e ), "error" )
12321245 request .actiondb .approve_run (username = username , run = run )
12331246 cached_flash (request , message )
12341247 return home (request )
@@ -1367,11 +1380,13 @@ def tests_view(request):
13671380 "new_options" ,
13681381 "resolved_new" ,
13691382 "new_net" ,
1383+ "new_nets" ,
13701384 "base_tag" ,
13711385 "base_signature" ,
13721386 "base_options" ,
13731387 "resolved_base" ,
13741388 "base_net" ,
1389+ "base_nets" ,
13751390 "sprt" ,
13761391 "num_games" ,
13771392 "spsa" ,
@@ -1401,6 +1416,9 @@ def tests_view(request):
14011416 if name == "base_tag" and "msg_base" in run ["args" ]:
14021417 value += " (" + run ["args" ]["msg_base" ][:50 ] + ")"
14031418
1419+ if name in ("new_nets" , "base_nets" ):
1420+ value = ", " .join (value )
1421+
14041422 if name == "sprt" and value != "-" :
14051423 value = "elo0: {:.2f} alpha: {:.2f} elo1: {:.2f} beta: {:.2f} state: {} ({})" .format (
14061424 value ["elo0" ],
0 commit comments