("Type[Transform]", get_transform_type), ("Trial", get_trial), ] # This map records discrepancies between Python and JSON representations, # so that we can validate that the JSON representation is complete # -- Sometimes a field appears in the Python object but not the JSON # (because it is not strictly necessary to store) # -- Sometimes a field appears in both places but with different names # (because the name used by JSON is the name used by the constructor, # might not be the same used by the attribute) ENCODE_DECODE_FIELD_MAPS = { "Experiment": EncodeDecodeFieldsMap( python_only=[ "arms_by_signature", "arms_by_name", "trial_indices_by_status", "trials_have_ttl", ] ), "BatchTrial": EncodeDecodeFieldsMap( python_only=["experiment"], python_to_encoded={"BaseTrial__status": "status"} ), "SimpleBenchmarkProblem": EncodeDecodeFieldsMap(encoded_only=["function_name"]), "GenerationStrategy": EncodeDecodeFieldsMap( python_only=["uses_registered_models", "seen_trial_indices_by_status"], encoded_only=["had_initialized_model", "db_id"], python_to_encoded={"curr": "curr_index"}, ), "GeneratorRun": EncodeDecodeFieldsMap( encoded_only=["arms", "weights"], python_only=["arm_weight_table"] ),
("SumConstraint", get_sum_constraint1), ("SumConstraint", get_sum_constraint2), ("SyntheticRunner", get_synthetic_runner), ("Type[Transform]", get_transform_type), ("Trial", get_trial), ] # This map records discrepancies between Python and JSON representations, # so that we can validate that the JSON representation is complete # -- Sometimes a field appears in the Python object but not the JSON # (because it is not strictly necessary to store) # -- Sometimes a field appears in both places but with different names # (because the name used by JSON is the name used by the constructor, # might not be the same used by the attribute) ENCODE_DECODE_FIELD_MAPS = { "Experiment": EncodeDecodeFieldsMap(python_only=["arms_by_signature"]), "BatchTrial": EncodeDecodeFieldsMap(python_only=["experiment"]), "SimpleBenchmarkProblem": EncodeDecodeFieldsMap(encoded_only=["function_name"]), "GenerationStrategy": EncodeDecodeFieldsMap( python_only=["model", "uses_registered_models"], encoded_only=["had_initialized_model"], python_to_encoded={"curr": "curr_index"}, ), "GeneratorRun": EncodeDecodeFieldsMap( encoded_only=["arms", "weights"], python_only=["arm_weight_table"] ), "OrderConstraint": EncodeDecodeFieldsMap( python_only=["bound"], python_to_encoded={ "lower_parameter": "lower_name", "upper_parameter": "upper_name",
), ( "SumConstraint", get_sum_constraint2, Encoder.parameter_constraint_to_sqa, Decoder.parameter_constraint_from_sqa, ), ("Trial", get_trial, Encoder.trial_to_sqa, Decoder.trial_from_sqa), ] # This map records discrepancies between Python and SQA representations, # so that we can validate that the SQA representation is complete ENCODE_DECODE_FIELD_MAPS = { "AbandonedArm": EncodeDecodeFieldsMap(python_to_encoded={ "reason": "abandoned_reason", "time": "time_abandoned" }), "Arm": EncodeDecodeFieldsMap(encoded_only=["weight"], python_to_encoded={"parameters": "parameters"}), "BatchTrial": EncodeDecodeFieldsMap( python_to_encoded={ "generator_run_structs": "generator_runs", "abandoned_arms_metadata": "abandoned_arms", "num_arms_created": "num_arms_created", }, python_only=["experiment", "status_quo", "status_quo_weight"], encoded_only=["is_batch", "status_quo_name"], ), "BraninObjective":
("Type[Transform]", get_transform_type), ("Trial", get_trial), ] # This map records discrepancies between Python and JSON representations, # so that we can validate that the JSON representation is complete # -- Sometimes a field appears in the Python object but not the JSON # (because it is not strictly necessary to store) # -- Sometimes a field appears in both places but with different names # (because the name used by JSON is the name used by the constructor, # might not be the same used by the attribute) ENCODE_DECODE_FIELD_MAPS = { "Experiment": EncodeDecodeFieldsMap(python_only=[ "arms_by_signature", "arms_by_name", "trial_indices_by_status", "trials_have_ttl", ]), "BatchTrial": EncodeDecodeFieldsMap(python_only=["experiment"], python_to_encoded={"BaseTrial__status": "status"}), "SimpleBenchmarkProblem": EncodeDecodeFieldsMap(encoded_only=["function_name"]), "GenerationStrategy": EncodeDecodeFieldsMap( python_only=["uses_registered_models", "seen_trial_indices_by_status"], encoded_only=["had_initialized_model", "db_id"], python_to_encoded={"curr": "curr_index"}, ), "GeneratorRun": EncodeDecodeFieldsMap(encoded_only=["arms", "weights"],
), ( "SumConstraint", get_sum_constraint2, Encoder.parameter_constraint_to_sqa, Decoder.parameter_constraint_from_sqa, ), ("Trial", get_trial, Encoder.trial_to_sqa, Decoder.trial_from_sqa), ] # This map records discrepancies between Python and SQA representations, # so that we can validate that the SQA representation is complete ENCODE_DECODE_FIELD_MAPS = { "Metric": EncodeDecodeFieldsMap(encoded_only={ "scalarized_objective_children_metrics", "scalarized_objective_weight", }), "AbandonedArm": EncodeDecodeFieldsMap(python_to_encoded={ "reason": "abandoned_reason", "time": "time_abandoned" }), "Arm": EncodeDecodeFieldsMap(encoded_only=["weight"], python_to_encoded={"parameters": "parameters"}), "BatchTrial": EncodeDecodeFieldsMap( python_to_encoded={ "generator_run_structs": "generator_runs", "abandoned_arms_metadata": "abandoned_arms", "num_arms_created": "num_arms_created",
("SumConstraint", get_sum_constraint2), ("SyntheticRunner", get_synthetic_runner), ("Type[Transform]", get_transform_type), ("Trial", get_trial), ] # This map records discrepancies between Python and JSON representations, # so that we can validate that the JSON representation is complete # -- Sometimes a field appears in the Python object but not the JSON # (because it is not strictly necessary to store) # -- Sometimes a field appears in both places but with different names # (because the name used by JSON is the name used by the constructor, # might not be the same used by the attribute) ENCODE_DECODE_FIELD_MAPS = { "Experiment": EncodeDecodeFieldsMap(python_only=["arms_by_signature"]), "BatchTrial": EncodeDecodeFieldsMap(python_only=["experiment"]), "GenerationStrategy": EncodeDecodeFieldsMap( python_only=["model", "uses_registered_models"], encoded_only=["had_initialized_model"], python_to_encoded={"curr": "curr_index"}, ), "GeneratorRun": EncodeDecodeFieldsMap(encoded_only=["arms", "weights"], python_only=["arm_weight_table"]), "OrderConstraint": EncodeDecodeFieldsMap( python_only=["bound"], python_to_encoded={
("SumConstraint", get_sum_constraint1), ("SumConstraint", get_sum_constraint2), ("SyntheticRunner", get_synthetic_runner), ("Trial", get_trial), ] # This map records discrepancies between Python and JSON representations, # so that we can validate that the JSON representation is complete # -- Sometimes a field appears in the Python object but not the JSON # (because it is not strictly necessary to store) # -- Sometimes a field appears in both places but with different names # (because the name used by JSON is the name used by the constructor, # might not be the same used by the attribute) ENCODE_DECODE_FIELD_MAPS = { "Experiment": EncodeDecodeFieldsMap(python_only=["arms_by_signature"]), "BatchTrial": EncodeDecodeFieldsMap(python_only=["experiment"]), "GeneratorRun": EncodeDecodeFieldsMap(encoded_only=["arms", "weights"], python_only=["arm_weight_table"]), "OrderConstraint": EncodeDecodeFieldsMap( python_only=["bound"], python_to_encoded={ "lower_parameter": "lower_name", "upper_parameter": "upper_name", }, ), "SimpleExperiment": EncodeDecodeFieldsMap(
), ( "SumConstraint", get_sum_constraint2, Encoder.parameter_constraint_to_sqa, Decoder.parameter_constraint_from_sqa, ), ("Trial", get_trial, Encoder.trial_to_sqa, Decoder.trial_from_sqa), ] # This map records discrepancies between Python and SQA representations, # so that we can validate that the SQA representation is complete ENCODE_DECODE_FIELD_MAPS = { "AbandonedArm": EncodeDecodeFieldsMap( python_to_encoded={"reason": "abandoned_reason", "time": "time_abandoned"} ), "Arm": EncodeDecodeFieldsMap( encoded_only=["weight"], python_to_encoded={"parameters": "parameters"} ), "BatchTrial": EncodeDecodeFieldsMap( python_to_encoded={ "generator_run_structs": "generator_runs", "abandoned_arms_metadata": "abandoned_arms", "num_arms_created": "num_arms_created", }, python_only=["experiment", "status_quo", "status_quo_weight_override"], encoded_only=["is_batch", "status_quo_name", "deployed_name"], ), "BraninObjective": EncodeDecodeFieldsMap( python_only=["metric"],
("SimpleExperiment", get_simple_experiment), ("SumConstraint", get_sum_constraint1), ("SumConstraint", get_sum_constraint2), ("SyntheticRunner", get_synthetic_runner), ("Trial", get_trial), ] # This map records discrepancies between Python and JSON representations, # so that we can validate that the JSON representation is complete # -- Sometimes a field appears in the Python object but not the JSON # (because it is not strictly necessary to store) # -- Sometimes a field appears in both places but with different names # (because the name used by JSON is the name used by the constructor, # might not be the same used by the attribute) ENCODE_DECODE_FIELD_MAPS = { "Experiment": EncodeDecodeFieldsMap(python_only=["arms_by_signature"]), "BatchTrial": EncodeDecodeFieldsMap(python_only=["experiment"]), "GeneratorRun": EncodeDecodeFieldsMap( encoded_only=["arms", "weights"], python_only=["arm_weight_table"] ), "OrderConstraint": EncodeDecodeFieldsMap( python_only=["bound"], python_to_encoded={ "lower_parameter": "lower_name", "upper_parameter": "upper_name", }, ), "SimpleExperiment": EncodeDecodeFieldsMap( python_only=["arms_by_signature", "evaluation_function"] ), "SumConstraint": EncodeDecodeFieldsMap(