Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed BSSH mock event generator script #682

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions docs/pipeline/automation/bssh_sqs_event_replay.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import ast
import json
#import os
from datetime import datetime, timezone
from urllib.parse import urlparse, ParseResult

#import pandas as pd
import requests

from urllib.parse import urlparse, ParseResult
from aws_requests_auth.boto_utils import BotoAWSRequestsAuth

# Usage:
# export AWS_PROFILE=prod
# python data/make_event.py

runs = [
["230602_A00130_0258_BH55TMDSX7","r.EgZe1CMokEKBAOInwt7WvQ"],
["230608_A01052_0153_AH53JWDSX7","r.ZbhluFYOykKAkMl6lztRwg"],
["230629_A01052_0154_BH7WF5DSX7","r.BDX5uxzx7EGVAVNiUHhcaw"],
["230707_A00130_0264_BH7WJTDSX7","r.Doo1NoNLkUedSP9Pud3ukQ"],
["230714_A01052_0158_AH7WGHDSX7","r.4zqT3NKkxUulz6mMCP3RkA"]
["230602_A00130_0258_BH55TMDSX7", "r.EgZe1CMokEKBAOInwt7WvQ"],
["230608_A01052_0153_AH53JWDSX7", "r.ZbhluFYOykKAkMl6lztRwg"],
["230629_A01052_0154_BH7WF5DSX7", "r.BDX5uxzx7EGVAVNiUHhcaw"],
["230707_A00130_0264_BH7WJTDSX7", "r.Doo1NoNLkUedSP9Pud3ukQ"],
["230714_A01052_0158_AH7WGHDSX7", "r.4zqT3NKkxUulz6mMCP3RkA"]
]


# ---


Expand All @@ -29,17 +27,17 @@ def get_event_tpl():
"Records": [
{
"messageId": "b2b8b423-3dd8-4aea-bbf2-f13108eaeb20",
"receiptHandle": "AQEB+PZKPwzpzgx7scoO5gFmC4hNDc+bPnmpG8hBmZ+loFXqEA7cH2i4TvtNcALsdB8wvUD1/M6DIHU+auIBnAidbQxYZqSQUEGlI8aye1hekSFiXVWI0IBj5tdy24TfCL3Yfm+T40NAJbft/wtV2hFM8eTL3gkIPoGzq1hyD396w5Av1uNkkbVRHZKEylVrDeRZkvjAsD/xl45lwtU+cF8fE95y/Q0Od1VYFQANEOtSK9YQm63irr+8Ce8TrAUQFhQ2RGUuXRBSSuVvYIPVLJ+LfZB0XaeNKmz53cf+M8M8/apGyU2go3m8tIgCJFRUqmB8l3vE+mAwHk7vvE+hTR5Gbukt+lgSqKhIfydsparQ7Q6JZANbUJSrHO+zOj8kyPHT6TW88dA7E8ulHw+lRUAhbqNGrQLBVWl/7Umg+d3/r2jhJ97leLSVcWz4nlHxsj0X",
"receiptHandle": "AQEB+PZKPwzpzgx7sc...LSVcWz4nlHxsj0X", # pragma: allowlist secret
"body": None,
"attributes": {
"ApproximateReceiveCount": "2",
"SentTimestamp": "1637706092924",
"SenderId": "AROARFCPI2IGXEV3HSTQ5:5cb0370d-7d39-4bb1-8108-ba27121643c4",
"SenderId": "AROARFCPI2IGX3HSTQ5:5cb0370d-7d39-4bb1-8108-ba27121643c4", # pragma: allowlist secret
"ApproximateFirstReceiveTimestamp": "1637706092925"
},
"messageAttributes": {
"subscription-urn": {
"stringValue": "urn:ilmn:igp:us-east-1:YXdzLXVzLXBsYXRmb3JtOjEwMDAwNTM3OjBiYTU5YWUxLWZkYWUtNDNiYS1hM2I1LTRkMzY3YTQzYWJkNQ:subscription:sub.1025",
"stringValue": "urn:ilmn:igp:us-east-1:YX.NQ:subscription:sub.1025", # pragma: allowlist secret
"stringListValues": [],
"binaryListValues": [],
"dataType": "String"
Expand Down Expand Up @@ -81,8 +79,8 @@ def get_event_tpl():
"dataType": "String"
}
},
"md5OfMessageAttributes": "18e31cf8c7e82c76901a7d29b0bd589d",
"md5OfBody": "fc38bcadba65d115d4eed663219b9e0c",
"md5OfMessageAttributes": "18e31cf8c7e82c7901a7d29b0bd589d", # pragma: allowlist secret
"md5OfBody": "fc38bcadba65d115d4ed663219b9e0c", # pragma: allowlist secret
"eventSource": "aws:sqs",
"eventSourceARN": "arn:aws:sqs:ap-southeast-2:472057503814:data-portal-prod-iap-ens-event-queue",
"awsRegion": "ap-southeast-2"
Expand All @@ -93,7 +91,7 @@ def get_event_tpl():
return event_tpl


def get_bssh_event(instrument_run_id, run_id, status="PendingAnalysis"):
def get_bssh_event(instrument_run_id_, run_id_, status="PendingAnalysis"):
obj: ParseResult = urlparse("https://api.data.prod.umccr.org/iam/sequencerun")

auth = BotoAWSRequestsAuth(
Expand All @@ -106,8 +104,8 @@ def get_bssh_event(instrument_run_id, run_id, status="PendingAnalysis"):
url=obj.geturl(),
auth=auth,
params={
'instrument_run_id': instrument_run_id,
'run_id': run_id,
'instrument_run_id': instrument_run_id_,
'run_id': run_id_,
'status': status,
}
)
Expand All @@ -119,8 +117,8 @@ def get_bssh_event(instrument_run_id, run_id, status="PendingAnalysis"):

for run in runs:
instrument_run_id = run[0]
run_id=run[1]
event = get_bssh_event(instrument_run_id=instrument_run_id, run_id=run_id)
run_id = run[1]
event = get_bssh_event(instrument_run_id_=instrument_run_id, run_id_=run_id)

results = event['results']
assert len(results) > 0
Expand Down