Skip to content
Snippets Groups Projects
Commit 52632bca authored by Daniel Nemergut's avatar Daniel Nemergut
Browse files

Getting the telescope from a calibration's exec block (ALMA doesn't have one,...

Getting the telescope from a calibration's exec block (ALMA doesn't have one, so assuming ALMA rather than looking for one)
parent 1c26be09
No related branches found
No related tags found
2 merge requests!1706merge 2.8.4 to main,!1666WS-2355 Calibration wrester telescope
Pipeline #15776 passed
......@@ -360,11 +360,13 @@ class WrestWorkflowMetadata:
query = """
SELECT sp.science_product_type,
COALESCE(eb.telescope,im.telescope) as telescope,
spp.project_code
spp.project_code,
c.execution_block_id
FROM science_products sp
JOIN science_products_projects spp ON sp.science_product_locator = spp.science_product_locator
LEFT JOIN execution_blocks eb ON sp.science_product_locator = eb.science_product_locator
LEFT JOIN images im ON sp.science_product_locator = im.science_product_locator
LEFT JOIN calibrations c ON sp.science_product_locator = c.science_product_locator
WHERE sp.science_product_locator = %(spl)s;
"""
make_json = {}
......@@ -388,9 +390,33 @@ class WrestWorkflowMetadata:
cursor.execute(query, {"spl": spl})
data = cursor.fetchall()
if data:
product_type = str(data[0][0]).lower().replace(" ", "_")
# Get the telescope from a calibration's exec block (if applicable)
if product_type != 'calibration':
telescope = data[0][1]
else:
if not data[0][3]:
# ALMA doesn't have a calibrations.execution_block_id, could query with the alm_ous_id, but meh
telescope = 'ALMA'
else:
# Can get it from the EB
scope_query = """
SELECT telescope
FROM execution_blocks
WHERE execution_block_id = %(eb_id)s;
"""
cursor.execute(scope_query, {"pg_id": data[0][3]})
scope_data = cursor.fetchall()
if scope_data:
telescope = data[0][0]
else:
self.logger.error(f"ERROR: Failed to determine telescope from calibration's EB, got {data}")
return make_json
make_json = {
"product_type": str(data[0][0]).lower().replace(" ", "_"),
"telescope": data[0][1],
"product_type": product_type,
"telescope": telescope,
"projectCode": data[0][2],
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment