Skip to content

Per-function requirements cannot use package include #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
chinalikai opened this issue Apr 9, 2018 · 5 comments
Open

Per-function requirements cannot use package include #168

chinalikai opened this issue Apr 9, 2018 · 5 comments
Labels

Comments

@chinalikai
Copy link

I use per-function requirements
├── serverless.yml
├── config
│ └── settings.py
├── function1
│ ├── requirements.txt
│ └── index.py
└── function2
├── requirements.txt
└── index.py

serverless.yml is
package:
individually: true

functions:
func1:
handler: index.handler
module: function1
func2:
handler: index.handler
module: function2
package:
include:
- config/**

issuse is : the config/** wouldn't be include in func2. how can didi it

@dschep
Copy link
Contributor

dschep commented Apr 9, 2018

Hmm. I think it'd work if you do:

cd function1
ln -s ../config
cd ../function2
ln -s ../config
cd ..
sls deploy

I agree that's not optimal, but I think it should work. Any input @cgrimal, since you implemented the per-function requirements?

@dschep dschep added the question label Apr 9, 2018
@cgrimal
Copy link

cgrimal commented Apr 9, 2018

I managed to reproduce the issue indeed. That said, the handling of linking (now injecting) has been completely reworked since i implemented this feature and I don't see where the include directive is supposed to be handled. It might be a bug I'm afraid.

Even though @dschep's workaround should work, you can also use the vendor mechanism. With your exact folder structures, it works with this minimal serverless.yml file:

service: issue_168

provider:
    name: aws
    runtime: python3.6

package:
    individually: true
    include:  # not working :'(
        - config/**

functions:
    func1:
        handler: index.handler
        module: function1
        vendor: ./config
    func2:
        handler: index.handler
        module: function2
        vendor: ./config

plugins:
  - serverless-python-requirements

You can run the sls package -v -f func1 command, and look into the function1.zip artefact created in the .serverless folder.

@chinalikai
Copy link
Author

@dschep @cgrimal thanks, i will use vendor temporary.

@antoniocaiazzo
Copy link

Hi @cgrimal, I have a very similar structure to OP (the folder is called common instead of config) and I've tried to use vendor as you suggested but the folder does not get included.

airwitsX3:
  handler: airwitsX3.handler
  module: iot/processing/airwitsX3
  vendor: ./common
  events:
    - stream:
        type: kinesis
        arn: "arn:aws:kinesis:${self:custom.region}:${self.custom.streamID}:stream/${self:custom.streamName}"

I have also tried @dschep's suggestion to put a symlink, this works but it's not possible to use exclude or slimPatterns anymore (I have a few tests in there).
I have tried to have a look in the source code but I'm not familiar with serverless plugin structure and cannot find the point where the vendor key is taken into account.

Is there a way to make either include or vendor work again?
Thanks!

@cgrimal
Copy link

cgrimal commented Mar 4, 2020

Hi @antoniocaiazzo, I'm afraid I haven't been using (or working on) this project for too long now, and I don't think I can help you. You'll have better chances if you open a new issue (you may still reference this one).

I hope you'll find a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants