From f79c0fa77680c9266cefbfec815be936f5382ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20S=C3=A1nchez-Gallego?= Date: Fri, 13 Dec 2024 17:39:15 -0800 Subject: [PATCH] Hardcode optical_prov to too for all ToO targets --- src/too/database.py | 3 +++ tests/test_database.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/too/database.py b/src/too/database.py index 34d9456..405abd6 100644 --- a/src/too/database.py +++ b/src/too/database.py @@ -117,6 +117,9 @@ def load_too_targets( bright_limit_checks=validate_magnitude_limits, ) + # We always want to set the optical_prov column to too. + targets = targets.with_columns(optical_prov=polars.lit("too")) + too_columns = ["too_id"] too_columns += [col for col in too_dtypes if col not in too_metadata_columns] diff --git a/tests/test_database.py b/tests/test_database.py index 5d030b7..b8f6717 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -103,6 +103,12 @@ def test_load_too_targets(too_mock: polars.DataFrame, caplog: pytest.LogCaptureF assert added.height == 10 assert catalogdb.ToO_Target.select().count() == 10 + assert ( + catalogdb.ToO_Metadata.select() + .where(catalogdb.ToO_Metadata.optical_prov == "too") + .count() + == 10 + ) # Repeat. No new targets should be added. added = load_too_targets(too_mock[0:10], catalogdb.database)