如何在Windows 10上解决AWS-python无服务器部署问题

时间:2020-07-23 18:38:35

标签: python amazon-web-services aws-lambda serverless

我正在尝试调用lambda函数,以从S3下载现有的lgbm模型并返回响应。请给我一些关于这个问题是什么以及可能的解决方案的想法。谢谢。

我的main.py文件如下:

def lambda_handler(event,context):
    bucket= boto3.resource('s3').Bucket('myBucket')
    bucket.download_file('saved_model.txt','/tmp/saved_model.txt')
    model= lightgbm.Booster(model_file='/tmp/saved_model.txt')
    sample = event['body']
    result = model.predict(sample)
    # result = predict(event)
    return {'StatusCode':200,
    'body':result[0]}

我的serverless.yml文件如下:

service: serverless-ml
app: serverless-ml-app

plugins:
  - serverless-python-requirements

provider:
  name: aws
  runtime: python3.7
  stage: dev

# you can overwrite defaults here
#  stage: dev
  region: us-east-1
  deploymentBucket:
    name : myBucket

# you can add statements to the Lambda function's IAM Role here
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "s3:GetObject"
      Resource: 
        - "arn:aws:s3:::myBucket/*"

custome:
  pythonRequirements:
    slim: true

functions:
  lgbm-lambda:
    name: lgbm-lambda-function
    handler : main.lambda_handler
    events :
    - http : POST /qualification

我在conda环境中运行这些文件,目录中的文件如下:

enter image description here

当我运行“无服务器部署”时,出现的错误是:

*** mynetwork can't find 169.254.169.254: Non-existent domain

Error: {"errorMessage":"Application not found. - Please contact support and provide this identifier to reference this issue - ZVZ6WTH2DM3W"}

0 个答案:

没有答案