77def only_persistent_gens (W , H , sim_specs , gen_specs , alloc_specs , persis_info , libE_info ):
88 """
99 This allocation function will give simulation work if possible, but
10- otherwise start up to ``alloc_specs["user"]["num_active_gens"]``
10+ otherwise start up to ``gen_specs["num_active_gens"]`` or `` alloc_specs["user"]["num_active_gens"]``
1111 persistent generators (defaulting to one).
1212
1313 By default, evaluation results are given back to the generator once
1414 all generated points have been returned from the simulation evaluation.
15- If ``alloc_specs["user"]["async_return"]`` is set to True, then any
15+ If ``gen_specs["async_return"]`` or `` alloc_specs["user"]["async_return"]`` is set to True, then any
1616 returned points are given back to the generator.
1717
1818 If any workers are marked as zero_resource_workers, then these will only
@@ -25,7 +25,7 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l
2525
2626 To be provided in calling script: E.g., ``alloc_specs["user"]["async_return"] = True``
2727
28- initial_batch_size : int, optional
28+ init_sample_size : int, optional
2929 Initial sample size - always return in batch. Default: 0
3030
3131 num_active_gens: int, optional
@@ -56,21 +56,20 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l
5656 return {}, persis_info
5757
5858 # Initialize alloc_specs["user"] as user.
59- user = alloc_specs .get ("user" , {})
59+ user = {** gen_specs , ** alloc_specs .get ("user" , {})}
60+
6061 manage_resources = libE_info ["use_resource_sets" ]
6162
62- active_recv_gen = gen_specs . get ( "active_recv_gen" , user .get ("active_recv_gen" , False ))
63- initial_batch_size = gen_specs . get ( "initial_batch_size" , user .get ("initial_batch_size" , 0 ))
64- batch_give = gen_specs . get ( "give_all_with_same_priority" , user .get ("give_all_with_same_priority" , False ) )
63+ active_recv_gen = user .get ("active_recv_gen" , False ) # Persistent gen can handle irregular communications
64+ initial_batch_size = user .get ("initial_batch_size" , 0 ) # Always batch return until this many evals complete
65+ batch_give = user .get ("give_all_with_same_priority" , False )
6566
6667 support = AllocSupport (W , manage_resources , persis_info , libE_info )
6768 gen_count = support .count_persis_gens ()
6869 Work = {}
6970
7071 # Asynchronous return to generator
71- async_return = (
72- gen_specs .get ("async_return" , user .get ("async_return" , False )) and sum (H ["sim_ended" ]) >= initial_batch_size
73- )
72+ async_return = user .get ("async_return" , False ) and sum (H ["sim_ended" ]) >= initial_batch_size
7473
7574 if gen_count < persis_info .get ("num_gens_started" , 0 ):
7675 # When a persistent worker is done, trigger a shutdown (returning exit condition of 1)
@@ -96,7 +95,7 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l
9695 # Now the give_sim_work_first part
9796 points_to_evaluate = ~ H ["sim_started" ] & ~ H ["cancel_requested" ]
9897 avail_workers = support .avail_worker_ids (persistent = False , zero_resource_workers = False , gen_workers = False )
99- if gen_specs . get ( "alt_type" , user .get ("alt_type" ) ):
98+ if user .get ("alt_type" ):
10099 avail_workers = list (
101100 set (support .avail_worker_ids (persistent = False , zero_resource_workers = False ))
102101 | set (support .avail_worker_ids (persistent = EVAL_SIM_TAG , zero_resource_workers = False ))
@@ -108,7 +107,7 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l
108107 sim_ids_to_send = support .points_by_priority (H , points_avail = points_to_evaluate , batch = batch_give )
109108
110109 try :
111- if gen_specs . get ( "alt_type" , user .get ("alt_type" ) ):
110+ if user .get ("alt_type" ):
112111 Work [wid ] = support .sim_work (
113112 wid , H , sim_specs ["in" ], sim_ids_to_send , persis_info .get (wid ), persistent = True
114113 )
@@ -124,7 +123,7 @@ def only_persistent_gens(W, H, sim_specs, gen_specs, alloc_specs, persis_info, l
124123 avail_workers = support .avail_worker_ids (persistent = False , zero_resource_workers = True , gen_workers = True )
125124
126125 for wid in avail_workers :
127- if gen_count < gen_specs . get ( "num_active_gens" , user .get ("num_active_gens" , 1 ) ):
126+ if gen_count < user .get ("num_active_gens" , 1 ):
128127 # Finally, start a persistent generator as there is nothing else to do.
129128 try :
130129 Work [wid ] = support .gen_work (
0 commit comments