def multi_objective_to_sqa()

in ax/storage/sqa_store/encoder.py [0:0]


    def multi_objective_to_sqa(self, multi_objective: MultiObjective) -> SQAMetric:
        """Convert Ax Multi Objective to SQLAlchemy.

        Returns: A parent `SQAMetric`, whose children are the `SQAMetric`-s
            corresponding to `metrics` attribute of `MultiObjective`.
            NOTE: The parent is used as a placeholder for storage purposes.
        """
        # Constructing children SQAMetric classes (these are the real metrics in
        # the `MultiObjective`).
        children_objectives = []
        for objective in multi_objective.objectives:
            objective_cls = cast(SQAMetric, self.config.class_to_sqa_class[Metric])
            type_and_properties = self.get_metric_type_and_properties(
                metric=objective.metric
            )
            children_objectives.append(
                objective_cls(  # pyre-ignore[29]: `SQAMetric` is not a func.
                    id=objective.metric.db_id,
                    name=objective.metric.name,
                    metric_type=type_and_properties[0],
                    intent=MetricIntent.OBJECTIVE,
                    minimize=objective.minimize,
                    properties=type_and_properties[1],
                    lower_is_better=objective.metric.lower_is_better,
                )
            )

        # Constructing a parent SQAMetric class (not a real metric, only a placeholder
        # to group the metrics together).
        parent_metric_cls = cast(SQAMetric, self.config.class_to_sqa_class[Metric])
        parent_metric = (
            parent_metric_cls(  # pyre-ignore[29]: `SQAMetric` is not a func.
                id=multi_objective.db_id,
                name="multi_objective",
                metric_type=self.config.metric_registry[Metric],
                intent=MetricIntent.MULTI_OBJECTIVE,
                scalarized_objective_children_metrics=children_objectives,
            )
        )
        return parent_metric