Skip to content

Commit

Permalink
Refresh cached schema on key miss.
Browse files Browse the repository at this point in the history
  • Loading branch information
ktlim committed May 16, 2024
1 parent 24410ef commit b1b3ec4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion python/lsst/consdb/pqserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,15 @@ def insert_flexible_metadata(
value_dict = info["values"]
for key, value in value_dict.items():
if key not in schema:
raise BadValueException("key", key, list(schema.keys()))
# Refresh cached schema
schema = dict()
stmt = sqlalchemy.select(schema_table.c["key", "dtype", "doc", "unit", "ucd"])
with engine.connect() as conn:
for row in conn.execute(stmt):
schema[row[0]] = row[1:]
instrument_tables.flexible_metadata_schemas[instrument][obs_type] = schema
if key not in schema:
raise BadValueException("key", key, list(schema.keys()))

# check value against dtype
dtype = schema[key][0]
Expand Down

0 comments on commit b1b3ec4

Please sign in to comment.