getlift / lift

Expanding Serverless Framework beyond functions using the AWS CDK
MIT License
912 stars 109 forks source link

Python lambda function created inside a queue does not install requirements.txt file #358

Open Pixcell opened 10 months ago

Pixcell commented 10 months ago

Hello,

Using lift queue construct, the created lambda does not include dependencies defined inside a requirements.txt file that can be found at the root of the folder containing the handler.

Folder struct:

src/
  artefacts/
     exporter/
        handler.py
        ....
        requirements.txt

serverless definition:

plugins:
  - serverless-python-requirements
  - serverless-prune-plugin
  - serverless-lift

 ....

constructs:
  rqd-export-artefacts:
    type: queue
    maxConcurrency: 5
    worker:
      role: ArtefactExporterRole
      handler: src/artefact/exporter/handler.handle
      timeout: 600
      environment:
        ...
    batchSize: 10

Any help would be greatly appreciated. I tried using layers, but I must be doing something wrong because the layer wont package with the error

Serverless: Configuration warning:
Serverless:   at 'functions.orchestrator_initialise': unrecognized property 'module'
Serverless:   at 'functions.orchestrator': unrecognized property 'module'
Serverless:  
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation
Serverless:  
Serverless: Generated requirements from /root/project/src/orchestrator/requirements.txt in /root/project/.serverless/src/orchestrator/requirements.txt...
Serverless: Installing requirements from /root/.python_library_cache/a1a842adba81ba6d4a86733fbadb121a75b89db3348d803d00ba75024ecf76b8_slspyc/requirements.txt ...
Serverless: Using download cache directory /root/.python_library_cache/downloadCacheslspyc
Serverless: Running ...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...

 Serverless Error ----------------------------------------

  No file matches include / exclude patterns

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              14.21.3
     Framework Version:         2.63.0 (local)
     Plugin Version:            5.4.8
     SDK Version:               4.3.0
     Components Version:        3.17.1

Exited with code exit status 1

Thank you!

mnapoli commented 10 months ago

Hi, could it be that the python plugin runs after Lift declares the "worker" function? (and so the Python plugin doesn't detect the worker function)