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

invalidateCaches not working

Open andriy-pankiv-lemberg opened this issue 4 years ago • 4 comments

Hi, I am using your npm package and get into issue that serverless-python-requirements is still using cached requirements even if invalidateCaches is set to true. I am trying to install custom python library that is pulled with gitsubmodules. Here is part of my serverless.yml

service: image-processor

plugins:
  - serverless-offline-python
  - serverless-python-requirements

custom:
  pythonRequirements:
    invalidateCaches: true
    dockerizePip: non-linux

serverless deploy output

Serverless: Generated requirements from /home/andriy/PycharmProjects/backend-interface-aws-lambda/requirements.txt in /home/andriy/PycharmProjects/backend-interface-aws-lambda/.serverless/requirements.txt...
Serverless: Using static cache of requirements found at /home/andriy/.cache/serverless-python-requirements/bd11ca0a44be0485a0d88746542673de7055ebebb613ce84951378a3cb2771c5_slspyc ...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Injecting required Python packages to package...
Serverless: Installing dependencies for custom CloudFormation resources...
Serverless: WARNING: Function resize has timeout of 120 seconds, however, it's attached to API Gateway so it's automatically limited to 30 seconds.
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service image-processor.zip file to S3 (18.23 KB)...
Serverless: Uploading custom CloudFormation resources...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...

As you can see it is still using cached requirements - "Using static cache of requirements found at...." despite that invalidateCaches is set to true.

AWS Lambdas are deployed with next command:

sls deploy -s dev

Maybe I am doing something wrong? Or maybe use case is not valid?

P.S. This is my first ever issue submission, if there is lack of provided information or format is incorrect - feel free to ask for issue content update

andriy-pankiv-lemberg avatar Jun 04 '20 17:06 andriy-pankiv-lemberg

Any solution for that? It is extremely inconvenient to use your extension with custom Python packages, and I am sure I am not only one with this issue. invalidateCaches: true do nothing at all I am forced to go to /home/andriy/.cache/serverless-python-requirements and delete it manually every time custom Python package is updated

andriy-pankiv-lemberg avatar Jun 11 '20 13:06 andriy-pankiv-lemberg

+1

mbrg avatar Dec 27 '20 14:12 mbrg

Looks like this is the same issue as this: https://github.com/serverless/serverless-python-requirements/issues/529 Since the latter has more information I propose to close this one.

Note that this issue 523 has the additional complaint about invalidateCaches not working.

f00f avatar Aug 03 '22 10:08 f00f

I'm trying to speed up redeploys with caching and hitting this problem (although it might not be the right solution anyway, because I'm trying to speed up CI/CD, whereas this might be for doing package once and deploy repeatedly?)

From a little bit of debugging, it seems that the after:package:cleanup hook gets called, but the promise never gets resolved and so clean() from lib/clean.js never gets invoked.

But if I run sls requirements clean then it does get invoked.

If I change this line to BbPromise.bind(this).then(cleanup).then(removeVendorHelper); (to match the definition from const clean further up the file) then it does get invoked. I don't know if that means anything to people more familiar with JavaScript and BbPromise.

StuartBertram avatar Mar 26 '24 13:03 StuartBertram