Skip to content
Snippets Groups Projects

WS-1893 curator workflow

Merged Daniel Nemergut requested to merge ws1893-curator_workflow into 2.8.2.1-DEVELOMENT
All threads resolved!
3 files
+ 47
0
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -348,3 +348,39 @@ class WrestWorkflowMetadata:
self.conn.close()
return make_json
def wrest_curator(self) -> json:
"""
Given a locator, returns the product information necessary to run curator on it.
:return: JSON containing product information.
"""
query = """
SELECT sp.science_product_type,
eb.telescope,
eb.project_code
FROM science_products sp
JOIN execution_blocks eb ON sp.science_product_locator = eb.science_product_locator
WHERE sp.science_product_locator = %(spl)s;
"""
make_json = {}
try:
cursor = self.conn.cursor()
cursor.execute(query, {"spl": self.spl[0]})
data = cursor.fetchall()
if data:
make_json = json.dumps(
{
"product_type": str(data[0][0]).lower().replace(' ', '_'),
"telescope": data[0][1],
"projectCode": data[0][2]
}
)
else:
self.logger.error(
f"ERROR: aat-wrest query returned no results!"
f" The database appears to be missing information for spl id {self.spl[0]}!"
)
finally:
self.conn.close()
return make_json
Loading