Skip to content

Commit 51f7b89

Browse files
authored
Broken PR build fix (#10556)
* Update run_ci.sh * fix flake8 warning s3-lambda.py 1. Two blank lines before the function definition (E302). 2. Four-space indentation (E111, E114). 3. Spaces around operators (E225). 4. Correct alignment for comments.
1 parent 4d5756f commit 51f7b89

File tree

2 files changed

+39
-35
lines changed

2 files changed

+39
-35
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
import boto3
22
import json
33

4-
def lambda_handler(event, context):
54

6-
# i want to know that event thing
7-
print(event)
5+
def lambda_handler(event, context):
6+
# i want to know that event thing
7+
print(event)
88

9-
# extract relevant information from the s3 event trigger
10-
bucket_name=event['Records'][0]['s3']['bucket']['name']
11-
object_key=event['Records'][0]['s3']['object']['key']
9+
# extract relevant information from the s3 event trigger
10+
bucket_name = event['Records'][0]['s3']['bucket']['name']
11+
object_key = event['Records'][0]['s3']['object']['key']
1212

13-
# perform desired operations with the upload file
14-
print(f"File '{object_key}' was uploaded to bucket '{bucket_name}'")
13+
# perform desired operations with the uploaded file
14+
print(f"File '{object_key}' was uploaded to bucket '{bucket_name}'")
1515

16-
# example: send a notification via sns
17-
sns_client=boto3.client('sns')
18-
topic_arn='arn:aws:sns:us-east-1:<account-id>:s3-lambda-sns'
19-
sns_client.publish(
20-
TopicArn=topic_arn,
21-
Subject='s3 object created !!',
22-
Message=f"File '{object_key}' was uploaded to bucket '{bucket_name}"
23-
)
16+
# example: send a notification via SNS
17+
sns_client = boto3.client('sns')
18+
topic_arn = 'arn:aws:sns:us-east-1:<account-id>:s3-lambda-sns'
19+
sns_client.publish(
20+
TopicArn=topic_arn,
21+
Subject='s3 object created !!',
22+
Message=f"File '{object_key}' was uploaded to bucket '{bucket_name}'"
23+
)
2424

25-
# Example: Trigger another Lambda function
26-
# lambda_client = boto3.client('lambda')
27-
# target_function_name = 'my-another-lambda-function'
28-
# lambda_client.invoke(
29-
# FunctionName=target_function_name,
30-
# InvocationType='Event',
31-
# Payload=json.dumps({'bucket_name': bucket_name, 'object_key': object_key})
32-
# )
33-
# in case of queuing and other objective similar to the netflix flow of triggering
25+
# Example: Trigger another Lambda function
26+
# lambda_client = boto3.client('lambda')
27+
# target_function_name = 'my-another-lambda-function'
28+
# lambda_client.invoke(
29+
# FunctionName=target_function_name,
30+
# InvocationType='Event',
31+
# Payload=json.dumps({'bucket_name': bucket_name, 'object_key': object_key})
32+
# )
33+
# in case of queuing and other objectives similar to the Netflix flow of triggering
3434

35-
return {
36-
'statusCode': 200,
37-
'body': json.dumps("Lambda function executed successfully !!")
38-
}
35+
return {
36+
'statusCode': 200,
37+
'body': json.dumps("Lambda function executed successfully !!")
38+
}

scripts/run_ci.sh

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22

33
set -euo pipefail
44

5-
PROJECT_DIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/.."
5+
PROJECT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/.."
66

7-
MD_FILES=$(find ${PROJECT_DIR} -name "*.md" -not -path "${PROJECT_DIR}/tests/*")
8-
9-
for file in ${MD_FILES[@]}; do
10-
python ${PROJECT_DIR}/tests/syntax_lint.py ${file} > /dev/null
7+
# Use the `-print0` option to handle spaces safely, and while-read loop:
8+
find "${PROJECT_DIR}" \
9+
-name "*.md" \
10+
-not -path "${PROJECT_DIR}/tests/*" \
11+
-print0 |
12+
while IFS= read -r -d '' file
13+
do
14+
python "${PROJECT_DIR}/tests/syntax_lint.py" "${file}" > /dev/null
1115
done
1216

1317
echo "- Syntax lint tests on MD files passed successfully"
1418

15-
flake8 --max-line-length=100 . && echo "- PEP8 Passed"
19+
flake8 --max-line-length=100 . && echo "- PEP8 Passed"

0 commit comments

Comments
 (0)