Код: Выделить всё
import json
import time
t = time.time()
print('This ')
import os
import urllib.parse
import boto3
import pandas as pd
import awswrangler as wr
print('Imports complete: ', time.time() - t)
s3 = boto3.client('s3')
def lambda_handler(event, context):
bucket = os.environ['S3_BUCKET']
try:
print('wrangling df')
df = wr.s3.read_parquet(bucket, dataset=True)
print('df loaded: ',time.time() - t)
response = df.to_json()
print('response type: ', type(response))
print('df to json: ',time.time() - t)
return response
except Exception as e:
print('exception caught: ',time.time() - t)
print(e)
print('Error getting object from bucket {}. Make sure they exist and your bucket is in the same region as this function.'.format(bucket))
raise e
Код: Выделить всё
arn:aws:lambda:eu-west-2:336392948345:layer:AWSSDKPandas-Python312:13
Код: Выделить всё
Test Event Name
(unsaved) test event
Response
{
"errorType": "Sandbox.Timedout",
"errorMessage": "RequestId: 24b0f94f-a78e-40e4-9573-0e49ac3eeef3 Error: Task timed out after 60.00 seconds"
}
Function Logs
This
Imports complete: 4.597054481506348
START RequestId: 24b0f94f-a78e-40e4-9573-0e49ac3eeef3 Version: $LATEST
wrangling df
df loaded: 10.094886779785156
response type:
df to json: 10.67463231086731
END RequestId: 24b0f94f-a78e-40e4-9573-0e49ac3eeef3
REPORT RequestId: 24b0f94f-a78e-40e4-9573-0e49ac3eeef3 Duration: 60000.00 ms Billed Duration: 60000 ms Memory Size: 128 MB Max Memory Used: 126 MB Init Duration: 4874.63 ms Status: timeout
Request ID
24b0f94f-a78e-40e4-9573-0e49ac3
Подробнее здесь: https://stackoverflow.com/questions/790 ... -statement