serverless-python-requirements icon indicating copy to clipboard operation
serverless-python-requirements copied to clipboard

Vendor property error when used with a function (unrecognized property 'vendor')

Open daxiang28 opened this issue 2 years ago • 2 comments

I'm getting the following error when adding a 'vendor' property to a function.

Warning: Invalid configuration encountered at 'functions.hello': unrecognized property 'vendor'

For context, this is an attempt to keep task functions inside a Django mono-repo and have these smaller task functions utilize shared code at the app root. I wasn't able to get relative imports to work and am looking at this vendor option. I'm open to other suggestions for how others have handled this.

Additionally, I'm not entirely sure if vendor is able to take a list of project folders (example in the serverless.yml below)

Project Structure

app_root
|_ serverless.yml
|_ __init__.py
|_ core
|_ more_stuff
|_ tasks
    |_ __init__.py
    |_ handlers
        |_ __init__.py
        |_ my_handler.py

serverless.yml

configValidationMode: warn
useDotenv: true
deprecationNotificationMode: warn:summary

plugins:
  - serverless-offline
  - serverless-prune-plugin
  - serverless-python-requirements
  - serverless-step-functions
  - serverless-step-functions-local
  - serverless-wsgi

custom:
  pythonRequirements:
    usePoetry: false
    dockerFile: Dockerfile
    zip: true
    useDownloadCache: true
    useStaticCache: true
    dockerizePip: true
    slim: true 
    strip: false
    pipCmdExtraArgs:
      - '-v'
      - '--log'
      - 'pip.log'
  stage: ${opt:stage, 'staging'}
  wsgi:
    app: core.wsgi.application
    packRequirements: false
  prune:
    automatic: true
    number: 3

functions:
  hello:
    handler: my_handler.handler
    module: tasks/handlers
    vendor:
    - ./core
    - ./more_stuff
    package:
      individually: true
        - 'core/**'
        - 'more_stuff/**'
        - 'wsgi_handler.py'
        - 'manage.py'
        - 's_app.py'
        - 'serverless_wsgi.py'
        - '.serverless-wsgi'
        - '!**/tests/**'
        - '!**/static/**'
    layers:
      - arn:aws:lambda:${self:provider.region}:770693421928:layer:Klayers-p39-boto3:1

provider:
  name: aws
  memorySize: 2056
  region: us-east-1
  runtime: python3.9
  versionFunctions: false
  stage: ${self:custom.stage}
  timeout: 30
  deploymentBucket:
    name: ${env:DEPLOYMENT_BUCKET}
  apiGateway:
    shouldStartNameWithService: true
  environment: ${file(./serverless/environment.yml)}

package:
  individually: true
  excludeDevDependencies: true
  patterns:
    - '!**'

package.json

    "@fernthedev/serverless-offline-step-functions": "^1.0.0-alpha.28",
    "serverless": "^3.7.0",
    "serverless-offline": "^8.5.0",
    "serverless-offline-lambda": "^1.0.6",
    "serverless-prune-plugin": "^2.0.1",
    "serverless-python-requirements": "^5.3.1",
    "serverless-step-functions": "^3.5.1",
    "serverless-step-functions-local": "^0.2.1",
    "serverless-wsgi": "^3.0.0"

daxiang28 avatar Mar 02 '22 16:03 daxiang28

Hello @daxiang28 - thanks for reporting. It seems like it was missed when schema was added here: https://github.com/serverless/serverless-python-requirements/blob/3edf0e0cabeeb11ffadd9dcac6f198f22aee4a16/index.js#L129

We'd be happy to accept a PR that adds that field to function schema 🙇

pgrzesik avatar Mar 02 '22 20:03 pgrzesik

Additionally, I'm not entirely sure if vendor is able to take a list of project folders

It doesn't seem to be stated anywhere that it does (are there any docs other than the readme & tutorial on Serverless site?) - but 👍🏻 I would like that too.

OJFord avatar Jun 20 '22 09:06 OJFord