(
    ax_client: AxClient,
    parallelism: Tuple[int, int],
    num_trials_so_far: int,
    num_max_trials_to_do: int,
)
return TrialBatch(
        list_of_trials=list_of_trials,
        is_search_space_exhausted=is_search_space_exhausted,
    )
Returns a TrialBatch that contains a list of trials that can be
    run in parallel. TrialBatch also flags if the search space is exhausted.
Returns a TrialBatch that contains a list of trials that can be
    run in parallel. TrialBatch also flags if the search space is exhausted.
Returns a TrialBatch that contains a list of trials that can be run in parallel . TrialBatch also flags if the search space is exhausted .
def get_one_batch_of_trials(
    ax_client: AxClient,
    parallelism: Tuple[int, int],
    num_trials_so_far: int,
    num_max_trials_to_do: int,
) -> TrialBatch:
    """Returns a TrialBatch that contains a list of trials that can be
    run in parallel. TrialBatch also flags if the search space is exhausted."""

    is_search_space_exhausted = False
    # Ax throws an exception if the search space is exhausted. We catch
    # the exception and set the flag to True
    (num_trials, max_parallelism_setting) = parallelism
    if max_parallelism_setting == -1:
        # Special case, we can group all the trials into one batch
        max_parallelism_setting = num_trials - num_trials_so_far

        if num_trials == -1:
            # This is a special case where we can run as many trials in parallel as we want.
            # Given that num_trials is also -1, we can run all the trials in parallel.
            max_parallelism_setting = num_max_trials_to_do

    list_of_trials = []
    for _ in range(max_parallelism_setting):
        try:
            parameters, trial_index = ax_client.get_next_trial()
            list_of_trials.append(
                Trial(
                    overrides=map_params_to_arg_list(params=parameters),
                    trial_index=trial_index,
                )
            )
        except SearchSpaceExhausted:
            is_search_space_exhausted = True
            break

    return TrialBatch(
        list_of_trials=list_of_trials,
        is_search_space_exhausted=is_search_space_exhausted,
    )
def get_one_batch_of_trials ( ax_client : AxClient , parallelism : Tuple [ int , int ] , num_trials_so_far : int , num_max_trials_to_do : int , ) -> TrialBatch : is_search_space_exhausted = False # Ax throws an exception if the search space is exhausted. We catch # the exception and set the flag to True ( num_trials , max_parallelism_setting ) = parallelism if max_parallelism_setting == - 1 : # Special case, we can group all the trials into one batch max_parallelism_setting = num_trials - num_trials_so_far if num_trials == - 1 : # This is a special case where we can run as many trials in parallel as we want. # Given that num_trials is also -1, we can run all the trials in parallel. max_parallelism_setting = num_max_trials_to_do list_of_trials = [ ] for _ in range ( max_parallelism_setting ) : try : parameters , trial_index = ax_client . get_next_trial ( ) list_of_trials . append ( Trial ( overrides = map_params_to_arg_list ( params = parameters ) , trial_index = trial_index , ) ) except SearchSpaceExhausted : is_search_space_exhausted = True break return TrialBatch ( list_of_trials = list_of_trials , is_search_space_exhausted = is_search_space_exhausted , )