Skip to content

Commit d93dc85

Browse files
committed
apply black formatting
1 parent 747414c commit d93dc85

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

broker/cloud_functions/lvk/store_BigQuery/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ else # Deploy the Cloud Functions
3939
--memory "${memory}" \
4040
--trigger-topic "${store_bq_trigger_topic}" \
4141
--set-env-vars TESTID="${testid}",SURVEY="${survey}",VERSIONTAG="${versiontag}",GCP_PROJECT="${GOOGLE_CLOUD_PROJECT}"
42-
fi
42+
fi

broker/cloud_functions/lvk/store_BigQuery/main.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
TABLE = pittgoogle.Table.from_cloud(f"alerts_{VERSIONTAG}", survey=SURVEY, testid=TESTID)
2323
TOPIC = pittgoogle.Topic.from_cloud("bigquery", survey=SURVEY, testid=TESTID, projectid=PROJECT_ID)
2424

25+
2526
def run(event: dict, _context: functions_v1.context.Context) -> None:
2627
"""Send alert data to various BigQuery tables.
2728
@@ -35,25 +36,25 @@ def run(event: dict, _context: functions_v1.context.Context) -> None:
3536
'context' is an unused argument in the function that is required
3637
see https://cloud.google.com/functions/1stgendocs/writing/write-event-driven-functions#background-functions
3738
"""
38-
39+
3940
# decode the base64-encoded message data
4041
decoded_data = base64.b64decode(event["data"])
4142

4243
# create a PubsubMessage-like object with the existing event dictionary
4344
pubsub_message = pubsub_v1.types.PubsubMessage(
44-
data=decoded_data,
45-
attributes=event.get("attributes", {})
45+
data=decoded_data, attributes=event.get("attributes", {})
4646
)
4747

4848
# unpack the alert
49-
alert = pittgoogle.Alert.from_msg(msg=pubsub_message,schema_name="default_schema")
50-
49+
alert = pittgoogle.Alert.from_msg(msg=pubsub_message, schema_name="default_schema")
50+
5151
# send the alert to BigQuery table
5252
alert_table = insert_rows_alerts(alert)
53-
53+
5454
# announce what's been done
5555
TOPIC.publish(_create_outgoing_alert(alert, alert_table))
5656

57+
5758
def insert_rows_alerts(alert: pittgoogle.alert.Alert):
5859
"""Insert rows into the `alerts` table via the streaming API."""
5960
# send to bigquery
@@ -69,14 +70,17 @@ def insert_rows_alerts(alert: pittgoogle.alert.Alert):
6970

7071
return table_dict
7172

72-
def _create_outgoing_alert(alert: pittgoogle.alert.Alert, table_dict: dict) -> pittgoogle.alert.Alert:
73+
74+
def _create_outgoing_alert(
75+
alert: pittgoogle.alert.Alert, table_dict: dict
76+
) -> pittgoogle.alert.Alert:
7377
"""Create an announcement of the table storage operation to Pub/Sub."""
7478
# collect attributes
7579
attrs = {
7680
**alert.attributes,
77-
"alerts_table": table_dict['alerts_table'],
78-
"alert_type": alert.dict['alert_type'],
79-
"superevent_id": alert.dict['superevent_id'],
81+
"alerts_table": table_dict["alerts_table"],
82+
"alert_type": alert.dict["alert_type"],
83+
"superevent_id": alert.dict["superevent_id"],
8084
}
8185

8286
# set empty message body; everything is in the attributes
@@ -86,5 +90,5 @@ def _create_outgoing_alert(alert: pittgoogle.alert.Alert, table_dict: dict) -> p
8690
alert_out = pittgoogle.Alert.from_dict(
8791
payload=msg, attributes=attrs, schema_name="default_schema"
8892
)
89-
90-
return alert_out
93+
94+
return alert_out

broker/cloud_functions/lvk/store_BigQuery/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
google-cloud-functions
77
google-cloud-logging
8-
pittgoogle-client>=0.3.11
8+
pittgoogle-client>=0.3.11

0 commit comments

Comments
 (0)