Skip to content
Snippets Groups Projects
Commit 8410a0bb authored by Daniel Nemergut's avatar Daniel Nemergut Committed by Charlotte Hausman
Browse files

Made a wrester for curator to collect product_type, telescope, and...

Made a wrester for curator to collect product_type, telescope, and project_code, couldn't think of a more clever name
parent c48535dc
No related branches found
No related tags found
3 merge requests!1571catch 2.8.2.3 up with main,!15592.8.2.2-DEVELOPMENT into main,!1551Cherry pick partial curation for patch
......@@ -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
......@@ -107,6 +107,13 @@ def parser() -> argparse.ArgumentParser:
required=False,
help="Find the basic product information for the provided product locator(s)",
)
arg_parser.add_argument(
"--curator",
nargs=1,
default=[],
required=False,
help="Find the product information necessary to run curator on the provided product locator",
)
return arg_parser
......@@ -140,6 +147,8 @@ def determine_wrester(connection: MDDBConnector, args: argparse.Namespace):
data = json.dumps({"reimaging_locator": reimaging_locator, "parameter_locator": parameter_locator})
elif args.product:
data = WrestWorkflowMetadata(connection, spl=args.product).wrest_product_info()
elif args.curator:
data = WrestWorkflowMetadata(connection, spl=args.curator).wrest_curator()
else:
data = None
......
......@@ -500,6 +500,8 @@ class WorkflowService(WorkflowServiceIF):
else parent_req.argument["sdmId"]
)
argument = eb
elif in_name("curator"):
wrest_type = "--curator"
else:
logger.info(f"No wrester found for workflow {name}. Does it actually require metadata?")
return wf_request
......
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