Exemplo n.º 1
0
def _load_experiment_info(exp: Experiment, exp_info: Dict[str, Any]) -> None:
    """Loads `Experiment` object with basic information."""
    exp._time_created = object_from_json(exp_info.get("time_created_json"))
    exp._trials = trials_from_json(exp, exp_info.get("trials_json"))
    exp._experiment_type = object_from_json(exp_info.get("experiment_type_json"))
    exp._data_by_trial = data_from_json(exp_info.get("data_by_trial_json"))
    for trial in exp._trials.values():
        for arm in trial.arms:
            exp._register_arm(arm)
        if trial.ttl_seconds is not None:
            exp._trials_have_ttl = True
    if exp.status_quo is not None:
        sq = not_none(exp.status_quo)
        exp._register_arm(sq)
Exemplo n.º 2
0
def experiment_from_json(object_json: Dict[str, Any]) -> Experiment:
    """Load Ax Experiment from JSON."""
    time_created_json = object_json.pop("time_created")
    trials_json = object_json.pop("trials")
    experiment_type_json = object_json.pop("experiment_type")
    data_by_trial_json = object_json.pop("data_by_trial")
    experiment = Experiment(**{k: object_from_json(v) for k, v in object_json.items()})
    experiment._time_created = object_from_json(time_created_json)
    experiment._trials = trials_from_json(experiment, trials_json)
    for trial in experiment._trials.values():
        for arm in trial.arms:
            experiment._arms_by_signature[arm.signature] = arm
    if experiment.status_quo is not None:
        sq_sig = experiment.status_quo.signature
        experiment._arms_by_signature[sq_sig] = experiment.status_quo
    experiment._experiment_type = object_from_json(experiment_type_json)
    experiment._data_by_trial = data_from_json(data_by_trial_json)
    return experiment
Exemplo n.º 3
0
Arquivo: decoder.py Projeto: bitnot/Ax
def experiment_from_json(object_json: Dict[str, Any]) -> Experiment:
    """Load Ax Experiment from JSON."""
    time_created_json = object_json.pop("time_created")
    trials_json = object_json.pop("trials")
    experiment_type_json = object_json.pop("experiment_type")
    data_by_trial_json = object_json.pop("data_by_trial")
    experiment = Experiment(
        **{k: object_from_json(v)
           for k, v in object_json.items()})
    experiment._time_created = object_from_json(time_created_json)
    experiment._trials = trials_from_json(experiment, trials_json)
    experiment._arms_by_name = {}
    for trial in experiment._trials.values():
        for arm in trial.arms:
            experiment._register_arm(arm)
        if trial.ttl_seconds is not None:
            experiment._trials_have_ttl = True
    if experiment.status_quo is not None:
        sq = not_none(experiment.status_quo)
        experiment._register_arm(sq)
    experiment._experiment_type = object_from_json(experiment_type_json)
    experiment._data_by_trial = data_from_json(data_by_trial_json)
    return experiment