-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqc-process2.py
More file actions
55 lines (46 loc) · 1.41 KB
/
qc-process2.py
File metadata and controls
55 lines (46 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import boto3
import time
import json
TABLE_NAME = 'QCSummary'
dynamodb_resource = boto3.resource('dynamodb')
table = dynamodb_resource.Table(TABLE_NAME)
def lambda_handler(event, context):
""" Perform QC process #2. Update flag in summary table """
group_id = event['GroupID']
start_time = event['StartTime']
stream_id = event['StreamID']
qc_pid = event['QCPID']
key = {
'GroupID': group_id,
'StartTime': start_time
}
process_item = {
'ProcessName': 'QCProcess2',
'GroupID': group_id,
'StartTime': start_time,
'QCPID': qc_pid,
'StreamID': stream_id
}
pass_fail = check_data_process2(group_id,stream_id)
process_item['Process2Pass'] = pass_fail
# Fake some processing time with a sleep
time.sleep(10)
response = table.update_item(
Key=key,
UpdateExpression="set Process2Pass=:p",
ExpressionAttributeValues={
':p': pass_fail
},
ReturnValues="UPDATED_NEW"
)
print(f"Response {response}")
return process_item
def check_data_process2(group_id,stream_id):
""" Process QC checks #2 for group/stream and mark as pass/fail """
passfail = 1
return passfail
if __name__ == '__main__':
with open('test_payloads/qc-process-event.json', 'r') as file:
data = file.read()
event = json.loads(data)
lambda_handler(event, 'context')