Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ax/storage/sqa_store/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,8 @@ def analysis_card_to_sqa(
) -> SQAAnalysisCard:
"""Convert Ax analysis to SQLAlchemy."""

ttl_timestamp = int(analysis_card._timestamp.timestamp())

# pyre-fixme: Expected `Base` for 1st...ot `typing.Type[BaseAnalysis]`.
analysis_card_class: SQAAnalysisCard = self.config.class_to_sqa_class[
AnalysisCard
Expand All @@ -1267,6 +1269,7 @@ def analysis_card_to_sqa(
experiment_id=experiment_id,
name=analysis_card.name,
timestamp=analysis_card._timestamp,
ttl_timestamp=ttl_timestamp,
order=order,
title=analysis_card.title,
subtitle=analysis_card.subtitle,
Expand Down Expand Up @@ -1307,6 +1310,7 @@ def analysis_card_to_sqa(
experiment_id=experiment_id,
name=card.name,
timestamp=card._timestamp,
ttl_timestamp=ttl_timestamp,
order=order,
title=card.title,
subtitle=card.subtitle,
Expand Down
3 changes: 3 additions & 0 deletions ax/storage/sqa_store/sqa_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ class SQAAnalysisCard(Base):
)
name: Mapped[str] = Column(String(NAME_OR_TYPE_FIELD_LENGTH), nullable=False)
timestamp: Mapped[datetime] = Column(IntTimestamp, nullable=False)
ttl_timestamp: Mapped[int] = Column(
BigInteger, nullable=False, server_default="18446744073709551615"
)

parent_id: Mapped[int | None] = Column(
Integer,
Expand Down
6 changes: 6 additions & 0 deletions ax/storage/sqa_store/tests/test_sqa_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
)
from ax.storage.sqa_store.sqa_classes import (
SQAAbandonedArm,
SQAAnalysisCard,
SQAArm,
SQAExperiment,
SQAGeneratorRun,
Expand Down Expand Up @@ -3085,6 +3086,11 @@ def test_analysis_card(self) -> None:
big_group,
self.experiment,
)
for saved_card in get_session().query(SQAAnalysisCard).all():
self.assertEqual(
saved_card.ttl_timestamp,
int(saved_card.timestamp.timestamp()),
)

with self.subTest("test_load_analysis_cards"):
loaded_analysis_cards = load_analysis_cards_by_experiment_name(
Expand Down
Loading