예제 #1
0
class SQAMetric(Base):
    __tablename__: str = "metric_v2"

    experiment_id: Optional[int] = Column(Integer,
                                          ForeignKey("experiment_v2.id"))
    generator_run_id: Optional[int] = Column(Integer,
                                             ForeignKey("generator_run_v2.id"))
    id: int = Column(Integer, primary_key=True)
    lower_is_better: Optional[bool] = Column(Boolean)
    intent: MetricIntent = Column(StringEnum(MetricIntent), nullable=False)
    metric_type: int = Column(Integer, nullable=False)
    name: str = Column(String(LONG_STRING_FIELD_LENGTH), nullable=False)
    properties: Optional[Dict[str, Any]] = Column(JSONEncodedTextDict,
                                                  default={})

    # Attributes for Objectives
    minimize: Optional[bool] = Column(Boolean)

    # Attributes for Outcome Constraints
    op: Optional[ComparisonOp] = Column(IntEnum(ComparisonOp))
    bound: Optional[float] = Column(Float)
    relative: Optional[bool] = Column(Boolean)

    # Multi-type Experiment attributes
    trial_type: Optional[str] = Column(String(NAME_OR_TYPE_FIELD_LENGTH))
    canonical_name: Optional[str] = Column(String(NAME_OR_TYPE_FIELD_LENGTH))

    immutable_fields = ["name", "metric_type"]
    unique_id = "name"
예제 #2
0
class SQAMetric(Base):
    __tablename__: str = "metric_v2"

    experiment_id: Optional[int] = Column(Integer,
                                          ForeignKey("experiment_v2.id"))
    generator_run_id: Optional[int] = Column(Integer,
                                             ForeignKey("generator_run_v2.id"))
    id: int = Column(Integer, primary_key=True)
    lower_is_better: Optional[bool] = Column(Boolean)
    intent: MetricIntent = Column(StringEnum(MetricIntent), nullable=False)
    metric_type: int = Column(Integer, nullable=False)
    name: str = Column(String(LONG_STRING_FIELD_LENGTH), nullable=False)
    properties: Optional[Dict[str, Any]] = Column(JSONEncodedTextDict,
                                                  default={})

    # Attributes for Objectives
    minimize: Optional[bool] = Column(Boolean)

    # Attributes for Outcome Constraints
    op: Optional[ComparisonOp] = Column(IntEnum(ComparisonOp))
    bound: Optional[float] = Column(Float)
    relative: Optional[bool] = Column(Boolean)

    # Multi-type Experiment attributes
    trial_type: Optional[str] = Column(String(NAME_OR_TYPE_FIELD_LENGTH))
    canonical_name: Optional[str] = Column(String(NAME_OR_TYPE_FIELD_LENGTH))

    immutable_fields = ["name"]
    unique_id = "name"

    scalarized_objective_id = Column(Integer, ForeignKey("metric_v2.id"))

    # Relationship containing SQAMetric(s) only defined for the parent metric
    # of Multi/Scalarized Objective contains all children of the parent metric
    # join_depth argument: used for loading self-referential relationships
    # https://docs.sqlalchemy.org/en/13/orm/self_referential.html#configuring-self-referential-eager-loading
    scalarized_objective_children_metrics = relationship(
        "SQAMetric",
        cascade="all, delete-orphan",
        lazy="selectin",
        join_depth=4)

    # Attribute only defined for the children of Scalarized Objective
    scalarized_objective_weight: Optional[float] = Column(Float)
예제 #3
0
class SQAMetric(Base):
    __tablename__: str = "metric_v2"

    # pyre-fixme[8]: Attribute has type `Optional[int]`; used as `Column[int]`.
    experiment_id: Optional[int] = Column(Integer,
                                          ForeignKey("experiment_v2.id"))
    # pyre-fixme[8]: Attribute has type `Optional[int]`; used as `Column[int]`.
    generator_run_id: Optional[int] = Column(Integer,
                                             ForeignKey("generator_run_v2.id"))
    # pyre-fixme[8]: Attribute has type `int`; used as `Column[int]`.
    id: int = Column(Integer, primary_key=True)
    # pyre-fixme[8]: Attribute has type `Optional[bool]`; used as `Column[bool]`.
    lower_is_better: Optional[bool] = Column(Boolean)
    # pyre-fixme[8]: Attribute has type `MetricIntent`; used as `Column[typing.Any]`.
    intent: MetricIntent = Column(StringEnum(MetricIntent), nullable=False)
    # pyre-fixme[8]: Attribute has type `int`; used as `Column[int]`.
    metric_type: int = Column(Integer, nullable=False)
    # pyre-fixme[8]: Attribute has type `str`; used as `Column[str]`.
    name: str = Column(String(LONG_STRING_FIELD_LENGTH), nullable=False)
    # pyre-fixme[8]: Attribute has type `Optional[Dict[str, typing.Any]]`; used as
    #  `Column[typing.Any]`.
    properties: Optional[Dict[str, Any]] = Column(JSONEncodedTextDict,
                                                  default={})

    # Attributes for Objectives
    # pyre-fixme[8]: Attribute has type `Optional[bool]`; used as `Column[bool]`.
    minimize: Optional[bool] = Column(Boolean)

    # Attributes for Outcome Constraints
    # pyre-fixme[8]: Attribute has type `Optional[ComparisonOp]`; used as
    #  `Column[typing.Any]`.
    op: Optional[ComparisonOp] = Column(IntEnum(ComparisonOp))
    # pyre-fixme[8]: Attribute has type `Optional[float]`; used as
    #  `Column[decimal.Decimal]`.
    bound: Optional[float] = Column(Float)
    # pyre-fixme[8]: Attribute has type `Optional[bool]`; used as `Column[bool]`.
    relative: Optional[bool] = Column(Boolean)

    # Multi-type Experiment attributes
    # pyre-fixme[8]: Attribute has type `Optional[str]`; used as `Column[str]`.
    trial_type: Optional[str] = Column(String(NAME_OR_TYPE_FIELD_LENGTH))
    # pyre-fixme[8]: Attribute has type `Optional[str]`; used as `Column[str]`.
    canonical_name: Optional[str] = Column(String(NAME_OR_TYPE_FIELD_LENGTH))

    scalarized_objective_id = Column(Integer, ForeignKey("metric_v2.id"))

    # Relationship containing SQAMetric(s) only defined for the parent metric
    # of Multi/Scalarized Objective contains all children of the parent metric
    # join_depth argument: used for loading self-referential relationships
    # https://docs.sqlalchemy.org/en/13/orm/self_referential.html#configuring-self-referential-eager-loading
    scalarized_objective_children_metrics = relationship(
        "SQAMetric",
        cascade="all, delete-orphan",
        lazy="selectin",
        join_depth=5,
        foreign_keys=[scalarized_objective_id],
    )

    # Attribute only defined for the children of Scalarized Objective
    # pyre-fixme[8]: Attribute has type `Optional[float]`; used as
    #  `Column[decimal.Decimal]`.
    scalarized_objective_weight: Optional[float] = Column(Float)

    scalarized_outcome_constraint_id = Column(Integer,
                                              ForeignKey("metric_v2.id"))
    scalarized_outcome_constraint_children_metrics = relationship(
        "SQAMetric",
        cascade="all, delete-orphan",
        lazy="selectin",
        join_depth=5,
        foreign_keys=[scalarized_outcome_constraint_id],
    )
    # pyre-fixme[8]: Attribute has type `Optional[float]`; used as
    #  `Column[decimal.Decimal]`.
    scalarized_outcome_constraint_weight: Optional[float] = Column(Float)