Serverless-python-requirements: Support per-function requirements

Created on 23 May 2017  ยท  5Comments  ยท  Source: UnitedIncome/serverless-python-requirements

It would be nice if different functions could have different requirements

example:

โ”œโ”€โ”€ serverless.yml
โ”œโ”€โ”€ function1
โ”‚      โ”œโ”€โ”€ requirements.txt
โ”‚      โ””โ”€โ”€ index.py
โ””โ”€โ”€ function2
       โ”œโ”€โ”€ requirements.txt
       โ””โ”€โ”€ index.py
enhancement help wanted

Most helpful comment

This is a good idea - but a little tricky. The way serverless framework handles individual zips under the hood is a little bit complex, so handling this may be wasteful of overall space. For functions with the same requirements, you'd end up with an almost-identical zip file & double the time to upload and such.

To do this well, there'd probably have to be a check of duplicate requirements so functions with the same ones could share an artifact.

All 5 comments

This is a good idea - but a little tricky. The way serverless framework handles individual zips under the hood is a little bit complex, so handling this may be wasteful of overall space. For functions with the same requirements, you'd end up with an almost-identical zip file & double the time to upload and such.

To do this well, there'd probably have to be a check of duplicate requirements so functions with the same ones could share an artifact.

Hello,

I would definitely like the implementation of this feature.
I am currently using gordon for some of my lambda deployments and I would like to switch to serverless. But in gordon I use a requirements.txt file per functions because some of my functions use heavy dependencies and I dont want them to affect the other light functions. Plus I'd like to mix some python and node into the same serverless project, including the python dependencies into the node lambdas feels a bit weird.

Following @ryansb work on #117 I think this could be relatively easily implemented by looking for a requirementsFileName under functions that overrides the custom.pythonRequirements.fileName option when using package.individually=true

Very interested by this enhancement as well!

Indeed, other plugins mentioned by @Tethik are focused on doing this, but I don't think they are compatible with serverless-python-requirements as they also implement the pip install process, but I feel like they are less features rich.
For example, even though these plugins implement the pip install process inside a docker container (useful for Numpy dependency, etc.) you can't have private repositories as requirements (see #69).

That's why I'd rather see this feature in this plugin. I'm gonna try to implement it, but as I'm quite new to the serverless environment (and not a very experienced node developer), I'll probably need some help! :smiley:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IanTayler picture IanTayler  ยท  4Comments

amadensor picture amadensor  ยท  3Comments

JulienMarliac picture JulienMarliac  ยท  3Comments

calclavia picture calclavia  ยท  5Comments

bsamuel-ui picture bsamuel-ui  ยท  3Comments