Ejemplo n.º 1
0
def trials_from_json(experiment: Experiment,
                     trials_json: Dict[str, Any]) -> Dict[int, BaseTrial]:
    """Load Ax Trials from JSON."""
    loaded_trials = {}
    for index, batch_json in trials_json.items():
        is_trial = batch_json["__type"] == "Trial"
        batch_json = {
            k: object_from_json(v)
            for k, v in batch_json.items() if k != "__type"
        }
        loaded_trials[int(index)] = (
            trial_from_json(experiment=experiment, **batch_json) if is_trial
            else batch_trial_from_json(experiment=experiment, **batch_json))
    return loaded_trials
Ejemplo n.º 2
0
def trials_from_json(
    experiment: Experiment,
    trials_json: Dict[str, Any],
    decoder_registry: Dict[str, Type],
    class_decoder_registry: Dict[str, Callable[[Dict[str, Any]], Any]],
) -> Dict[int, BaseTrial]:
    """Load Ax Trials from JSON."""
    loaded_trials = {}
    for index, batch_json in trials_json.items():
        is_trial = batch_json["__type"] == "Trial"
        batch_json = {
            k: object_from_json(
                v,
                decoder_registry=decoder_registry,
                class_decoder_registry=class_decoder_registry,
            )
            for k, v in batch_json.items() if k != "__type"
        }
        loaded_trials[int(index)] = (
            trial_from_json(experiment=experiment, **batch_json) if is_trial
            else batch_trial_from_json(experiment=experiment, **batch_json))
    return loaded_trials