def handle_dragen_wgs_qc_event(event): logger.info(f"Handling {util.EventType.DRAGEN_WGS_QC} event") event_type = event.get(util.BusEventKey.DETAIL_TYPE.value) if event_type != util.EventType.WRSC.value: raise ValueError(f"Unsupported event type: {event_type}") payload = event.get(util.BusEventKey.DETAIL.value) wrsc_event: wrsc.Event = wrsc.Marshaller.unmarshall(payload, typeName=wrsc.Event) if wrsc_event.status == "Succeeded": logger.info( f"{util.EventType.DRAGEN_WGS_QC.value} workflow succeeded! Proceeding to T/N." ) # only progress some libraries to mock T/N case lib_id = get_lib_id_from_wrsc_event(wrsc_event) if lib_id in ["L210001", "L210003"]: wfr_event = wfr.Event(library_id=lib_id) logger.info( f"Emitting DRAGEN_WGS_QC event with payload {wfr_event}") util.send_event_to_bus_schema( event_source=util.EventSource.ORCHESTRATOR, event_type=util.EventType.DRAGEN_WGS_SOMATIC, event_payload=wfr_event) else: # ignore other status for now logger.info( f"Received unsupported workflow status: {wrsc_event.status}")
def handle_bssh_runs_event(event): logger.info("Handling bssh.runs event") event_action = event['messageAttributes']['action']['stringValue'] if event_action != 'statuschanged': raise ValueError(f"Unexpected event action: {event_action}") message_body = json.loads(event['body']) # TODO: check difference between run name and instrument run ID srn = message_body['name'] iri = message_body['instrumentRunId'] if srn != iri: raise ValueError(f"Sequence run name and instrumentRunId are not the same! {srn} != {iri}") ev = srsc.Event( sequence_run_name=srn, sequence_run_id=message_body['id'], gds_folder_path=message_body['gdsFolderPath'], gds_volume_name=message_body['gdsVolumeName'], status=message_body['status'], timestamp=datetime.utcnow()) logger.info(f"Emitting {util.EventType.SRSC} event {ev}") util.send_event_to_bus_schema( event_type=util.EventType.SRSC, event_source=util.EventSource.ENS_HANDLER, event_payload=ev)
def handle_wes_runs_event(event): logger.info("Handling wes.runs event") event_action = event['messageAttributes']['action']['stringValue'] # TODO: check! should probably be 'updated' message_body = json.loads(event['body']) # TODO: convert SQS/ENS event into corresponding Portal event event_status = message_body['EventType'] # RunSucceeded event_time = message_body['Timestamp'] workflow_name = message_body['Name'] workflow_id = message_body['WorkflowRun']['Id'] # wfr.23487yq4508 workflow_status = message_body['WorkflowRun']['Status'] # Succeeded # Convert Pending status of WES launcher to Succeeded (simulating a successful WES run) if workflow_status == "Pending": workflow_status = "Succeeded" else: # We are receiving mock events from the WES launcher directly, those have all Pending status raise ValueError("Received non Pending WES run status! Only expect Pending at this point.") wrsc_event = wrsc.Event( workflow_run_name=workflow_name, workflow_run_id=workflow_id, status=workflow_status, timestamp=event_time ) logger.info(f"Emitting {util.EventType.SRSC} event {wrsc_event}") util.send_event_to_bus_schema( event_type=util.EventType.WRSC, event_source=util.EventSource.ENS_HANDLER, event_payload=wrsc_event)
def handler(event, context): logger.info("Starting dragen_wgs_qc handler") logger.info(json.dumps(event)) event_type = event.get(util.BusEventKey.DETAIL_TYPE.value) if event_type != util.EventType.DRAGEN_WGS_QC.value: raise ValueError(f"Unsupported event type: {event_type}") payload = event.get(util.BusEventKey.DETAIL.value) wfr_event: wfr.Event = wfr.Marshaller.unmarshall(payload, typeName=wfr.Event) workflow_input = { "library_id": wfr_event.library_id, "fastq_list_rows": {} } logger.info(f"Created workflow input: {workflow_input}") wf_name = f"{util.WorkflowType.DRAGEN_WGS_QC}_workflow_{wfr_event.library_id}" logger.info(f"Sending WES launch request for workflow {wf_name}") wes_launch_request = wlr.Event(workflow_run_name=wf_name, workflow_id="wfl.w94tygian4p8g4", workflow_version="3.7.5-34afe2c", workflow_input=workflow_input, timestamp=datetime.utcnow(), workflow_engine_parameters={}) logger.info( f"Emitting {util.EventType.WES_LAUNCH} request event: {wes_launch_request}" ) util.send_event_to_bus_schema(event_type=util.EventType.WES_LAUNCH, event_source=util.EventSource.DRAGEN_WGS_QC, event_payload=wes_launch_request) logger.info("All done.")
def submit_dragen_tso_ctdna_requests(libraries: list): # TODO: make sure that's not blocking other runs (i.e. a single WF failure should not prevent others) for lib in libraries: if lib.type == "TSO": # TODO: wfr_event = wfr.Event(library_id=lib.library_id) logger.info( f"Emitting DRAGEN_TSO_CTDNA event with payload {wfr_event}") util.send_event_to_bus_schema( event_source=util.EventSource.ORCHESTRATOR, event_type=util.EventType.DRAGEN_TSO_CTDNA, event_payload=wfr_event)
def handler(event, context): """ Lambda to prepare and trigger BCL CONVERT workflow runs. An event payload (detail) of the following format is expected: SequenceRunStateChange: { "sequence_run_name": "210525_A00100_0999_AHYYKD8MYX", "sequence_run_id": "r.c1IvasRL4U2MubrbB13cI4", 'gds_volume_name': "bssh.xxxx", 'gds_folder_path': "/Runs/210525_A00100_0999_AHYYKD8MYX_r.c1IvasRL4U2MubrbB13cI4", 'status': "", 'timestamp': "" } :param event: An AWSEvent with a SequenceRunStateChange event payload (detail) and SequenceRunStateChange detail-type :param context: Not used. :return: """ logger.info("Starting bcl_convert handler") logger.info(json.dumps(event)) event_type = event.get(util.BusEventKey.DETAIL_TYPE.value) if event_type != util.EventType.SRSC.value: raise ValueError(f"Unsupported event type: {event_type}") payload = event.get(util.BusEventKey.DETAIL.value) srsc_event: srsc.Event = srsc.Marshaller.unmarshall(payload, typeName=srsc.Event) workflow_input = { "seq_run_name": srsc_event.sequence_run_name, "seq_run_id": srsc_event.sequence_run_id, "gds_volume": srsc_event.gds_volume_name, "gds_path": srsc_event.gds_folder_path, "sample_sheet": f"gds://{srsc_event.gds_volume_name}{srsc_event.gds_folder_path}/SampleSheet.csv" } logger.info(f"Created workflow input: {workflow_input}") wf_name = f"{util.WorkflowType.BCL_CONVERT}_workflow_{srsc_event.sequence_run_name}_{srsc_event.sequence_run_id}" logger.info(f"Sending WES launch request for workflow {wf_name}") wes_launch_request = wlr.Event(workflow_run_name=wf_name, workflow_id="wfl.w94tygian4p8g4", workflow_version="3.7.5-34afe2c", workflow_input=workflow_input, timestamp=datetime.utcnow(), workflow_engine_parameters={}) logger.info( f"Emitting {util.EventType.WES_LAUNCH} request event: {wes_launch_request}" ) # mock: just forward on the payload util.send_event_to_bus_schema(event_type=util.EventType.WES_LAUNCH, event_source=util.EventSource.BCL_CONVERT, event_payload=wes_launch_request) logger.info("All done.")