From a1a13e9bafa6d4659f4ce80c1a65deb47841d05a Mon Sep 17 00:00:00 2001 From: Ray Liu Date: Wed, 4 Dec 2024 11:25:35 +1100 Subject: [PATCH] fix bssh event handler issue --- .../stacks/sequence-run-manager/deploy/stack.ts | 14 +++++++++----- .../lambdas/bssh_event.py | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/workload/stateless/stacks/sequence-run-manager/deploy/stack.ts b/lib/workload/stateless/stacks/sequence-run-manager/deploy/stack.ts index 6228cc321..8dcadd03e 100644 --- a/lib/workload/stateless/stacks/sequence-run-manager/deploy/stack.ts +++ b/lib/workload/stateless/stacks/sequence-run-manager/deploy/stack.ts @@ -134,7 +134,7 @@ export class SequenceRunManagerStack extends Stack { */ const procSqsFn = this.createPythonFunction('ProcHandler', { index: 'sequence_run_manager_proc/lambdas/bssh_event.py', - handler: 'sqs_handler', + handler: 'event_handler', timeout: Duration.minutes(2), memorySize: 512, reservedConcurrentExecutions: 1, @@ -146,9 +146,12 @@ export class SequenceRunManagerStack extends Stack { private setupEventRule(fn: aws_lambda.Function) { /** - * For - - */ + * For sequence run manager, we are using orcabus events ( source from BSSH ENS event pipe) to trigger the lambda function. + * event rule to filter the events that we are interested in. + * event pattern: see below + * process lambda will record the event to the database, and emit the 'SequenceRunStateChange' event to the event bus. + * + */ const eventRule = new Rule(this, this.stackName + 'EventRule', { ruleName: this.stackName + 'EventRule', description: 'Rule to send {event_type.value} events to the {handler.function_name} Lambda', @@ -158,11 +161,12 @@ export class SequenceRunManagerStack extends Stack { detailType: ['Event from aws:sqs'], detail: { 'ica-event': { - // only for mandatory fields + // mandatory fields (gdsFolderPath, gdsVolumeName(starts with bssh), instrumentRunId, dateModified) gdsFolderPath: [{ exists: true }], gdsVolumeName: [{ prefix: 'bssh' }], instrumentRunId: [{ exists: true }], dateModified: [{ exists: true }], + // optional fields (flowcell barcode, sample sheet name, reagent barcode, ica project id, api url, name) acl: [{ prefix: 'wid:' }, { prefix: 'tid:' }], id: [{ exists: true }], diff --git a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/lambdas/bssh_event.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/lambdas/bssh_event.py index f365f0998..f0a436214 100644 --- a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/lambdas/bssh_event.py +++ b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/lambdas/bssh_event.py @@ -104,6 +104,7 @@ def event_handler(event, context): sequence_domain: SequenceDomain = ( sequence_srv.create_or_update_sequence_from_bssh_event(event_details) ) + entry = None # Detect SequenceRunStateChange if sequence_domain.state_has_changed: