Skip to content

Commit

Permalink
Covert instrument names to lowercase in the validator
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrondel committed Jan 13, 2025
1 parent 25a4f57 commit c7c4870
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion python/lsst/consdb/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def validate_instrument_name(
instrument_lower = instrument.lower()
if instrument_lower not in [i.lower() for i in get_instrument_list()]:
raise UnknownInstrumentException(instrument)
return instrument
return instrument_lower


InstrumentName = Annotated[str, AfterValidator(validate_instrument_name)]
Expand Down
13 changes: 5 additions & 8 deletions python/lsst/consdb/handlers/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ def insert(
) -> InsertDataResponse:
"""Insert or update column/value pairs in a ConsDB table."""

instrument_l = instrument.lower()
schema = f"cdb_{instrument_l}."
schema = f"cdb_{instrument}."
table_name = table.lower()
if not table.lower().startswith(schema):
table_name = schema + table_name
Expand Down Expand Up @@ -316,13 +315,12 @@ def insert_multiple(
Raised if instrument or observation type is invalid.
"""

instrument_l = instrument.lower()
schema = f"cdb_{instrument_l}."
schema = f"cdb_{instrument}."
table_name = table.lower()
if not table.lower().startswith(schema):
table_name = schema + table_name
table_obj = instrument_table.schemas.tables[table_name]
table_name = f"cdb_{instrument_l}." + table.lower()
table_name = f"cdb_{instrument}." + table.lower()
obs_id_colname = instrument_table.obs_id_column[table_name]

timestamp_columns = instrument_table.get_timestamp_columns(table_name)
Expand Down Expand Up @@ -513,10 +511,9 @@ def schema(
Raised if instrument is invalid.
"""

instrument_l = instrument.lower()
schema = instrument_table.schemas
if not table.startswith(f"cdb_{instrument_l}."):
table = f"cdb_{instrument_l}.{table}"
if not table.startswith(f"cdb_{instrument}."):
table = f"cdb_{instrument}.{table}"
table = table.lower()
if table not in schema.tables:
raise BadValueException("table", table, list(schema.tables.keys()))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pqserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def test_flexible_metadata(lsstcomcamsim):
assert result == {
"message": "Key added to flexible metadata",
"key": "bar2",
"instrument": "LATISS",
"instrument": "latiss",
"obs_type": "exposure",
}

Expand Down

0 comments on commit c7c4870

Please sign in to comment.