Skip to content
Snippets Groups Projects
Commit 3657f3e7 authored by Charlotte Hausman's avatar Charlotte Hausman
Browse files

Merge branch 'tweaking-wresters' into '2.8.2.1-DEVELOMENT'

merge dicts, not strings

See merge request !1525
parents d1c142c5 856b98e8
No related branches found
No related tags found
2 merge requests!1605Merge 2.8.2.3 work to main,!1525merge dicts, not strings
Pipeline #12832 passed
...@@ -386,13 +386,12 @@ class WrestWorkflowMetadata: ...@@ -386,13 +386,12 @@ class WrestWorkflowMetadata:
cursor.execute(query, {"spl": spl}) cursor.execute(query, {"spl": spl})
data = cursor.fetchall() data = cursor.fetchall()
if data: if data:
make_json = json.dumps( make_json = {
{
"product_type": str(data[0][0]).lower().replace(" ", "_"), "product_type": str(data[0][0]).lower().replace(" ", "_"),
"telescope": data[0][1], "telescope": data[0][1],
"projectCode": data[0][2], "projectCode": data[0][2],
} }
)
else: else:
self.logger.error( self.logger.error(
f"ERROR: aat-wrest query returned no results!" f"ERROR: aat-wrest query returned no results!"
...@@ -454,7 +453,7 @@ class WrestWorkflowMetadata: ...@@ -454,7 +453,7 @@ class WrestWorkflowMetadata:
if data: if data:
# This should have all the ancillary and science product names # This should have all the ancillary and science product names
# It returns from the query as a list of tuples, so it must be flattened # It returns from the query as a list of tuples, so it must be flattened
make_json = json.dumps({"file_list": list(sum(data, ()))}) make_json = {"file_list": list(sum(data, ()))}
else: else:
self.logger.error(f"ERROR: Failed to fetch products from product ID {product_group_id}") self.logger.error(f"ERROR: Failed to fetch products from product ID {product_group_id}")
else: else:
...@@ -470,7 +469,7 @@ class WrestWorkflowMetadata: ...@@ -470,7 +469,7 @@ class WrestWorkflowMetadata:
cursor.execute(input_group_query, {"pg_id": product_group_id}) cursor.execute(input_group_query, {"pg_id": product_group_id})
input_data = cursor.fetchall() input_data = cursor.fetchall()
if input_data: if input_data:
input_info = json.dumps({"input_group_locator": input_data[0][0]}) input_info = {"input_group_locator": input_data[0][0]}
make_json = {**make_json, **input_info} make_json = {**make_json, **input_info}
finally: finally:
self.conn.close() self.conn.close()
......
...@@ -158,12 +158,13 @@ def determine_wrester(connection: MDDBConnector, args: argparse.Namespace): ...@@ -158,12 +158,13 @@ def determine_wrester(connection: MDDBConnector, args: argparse.Namespace):
elif args.product: elif args.product:
data = WrestWorkflowMetadata(connection, spl=args.product).wrest_product_info() data = WrestWorkflowMetadata(connection, spl=args.product).wrest_product_info()
elif args.curator: elif args.curator:
data = WrestWorkflowMetadata(connection, spl=args.curator).wrest_curator() data_dict = WrestWorkflowMetadata(connection, spl=args.curator).wrest_curator()
data = json.dumps(data_dict)
elif args.curator_products: elif args.curator_products:
general_data = WrestWorkflowMetadata(connection, spl=args.curator_products).wrest_curator() general_data = WrestWorkflowMetadata(connection, spl=args.curator_products).wrest_curator()
connection2 = MDDBConnector() connection2 = MDDBConnector()
product_data = WrestWorkflowMetadata(connection2, spl=args.curator_products).wrest_curator_products() product_data = WrestWorkflowMetadata(connection2, spl=args.curator_products).wrest_curator_products()
data = {**general_data, **product_data} data = json.dumps({**general_data, **product_data})
else: else:
data = None data = None
......
...@@ -874,6 +874,7 @@ def main(global_config, **settings): ...@@ -874,6 +874,7 @@ def main(global_config, **settings):
factory=lookup_request, factory=lookup_request,
) )
# route for retrieving a list of requests viable for clean up
config.add_route( config.add_route(
"list_stale_requests", "list_stale_requests",
"/workflows/requests/stale/{days}", "/workflows/requests/stale/{days}",
......
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