Title: Support per-function requierments with shared code · Issue #767 · serverless/serverless-python-requirements · GitHub
Open Graph Title: Support per-function requierments with shared code · Issue #767 · serverless/serverless-python-requirements
X Title: Support per-function requierments with shared code · Issue #767 · serverless/serverless-python-requirements
Description: Is there an existing issue for this? I have searched existing issues, it hasn't been reported yet Use case description See: #734 Besides it being a bug report, it describes the use case, also see: #168 #435 Currently I find the behavior ...
Open Graph Description: Is there an existing issue for this? I have searched existing issues, it hasn't been reported yet Use case description See: #734 Besides it being a bug report, it describes the use case, also see: ...
X Description: Is there an existing issue for this? I have searched existing issues, it hasn't been reported yet Use case description See: #734 Besides it being a bug report, it describes the use case, also s...
Opengraph URL: https://github.com/serverless/serverless-python-requirements/issues/767
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support per-function requierments with shared code","articleBody":"### Is there an existing issue for this?\r\n\r\n- [ ] I have searched existing issues, it hasn't been reported yet\r\n\r\n### Use case description\r\n\r\nSee: https://github.com/serverless/serverless-python-requirements/issues/734\r\n\r\nBesides it being a bug report, it describes the use case, also see:\r\nhttps://github.com/serverless/serverless-python-requirements/issues/168\r\nhttps://github.com/serverless/serverless-python-requirements/issues/435\r\n\r\nCurrently I find the behavior of per function requirements odd, because to me it seems it;s basically a more performant? implementation of https://www.serverless.com/framework/docs/guides/compose\r\n\r\nAs it uses the module as the entry point and thus you can not use shared code.\r\n\r\nProject structure:\r\n```\r\n- serverless.yml\r\n- application/**\r\n- domain/**\r\n- infrastructure/**\r\n- web\r\n - api.py\r\n - requirements.txt\r\n- events\r\n - handler.py\r\n - requirements.txt\r\n```\r\n\r\nserverless.yml:\r\n```\r\nservice: service\r\n\r\nprovider:\r\n name: aws\r\n runtime: python3.9\r\n\r\nfunctions:\r\n RESTAPI:\r\n handler: api.handler\r\n module: web\r\n package:\r\n patterns:\r\n - 'web/**'\r\n EventConsumer:\r\n handler: handler\r\n module: events\r\n package:\r\n patterns:\r\n - 'events/**'\r\n\r\npackage:\r\n individually: true\r\n patterns:\r\n - '!*'\r\n - '!*/**'\r\n - 'application/**'\r\n - 'domain/**'\r\n - 'infrastructure/**'\r\n\r\nplugins:\r\n - serverless-python-requirements\r\n\r\n```\r\n\r\nSo currently packaging this results in the following artifacts:\r\n```\r\n- events\r\n - requirements/**\r\n - requirements.txt\r\n- web\r\n - requirements/**\r\n - requirements.txt\r\n- cloudformation-template.json\r\n- events-service-stage-EventConsumer.zip\r\n- EventConsumer.zip\r\n- RESTAPI.zip\r\n- serverless-state.json\r\n- web-service-stage-RESTAPI.zip\r\n```\r\n\r\nThe RESTAPI zip file contains:\r\n```\r\n- application/**\r\n- domain/**\r\n- infrastructure/**\r\n- web/**\r\n```\r\nso the files and folderz defined in package patterns.\r\n\r\nand the web-service-stage-RESTAPI zip file contains the web requirements and the contents of the web folder in our project.\r\n\r\nWhen deploying the zips with the fully qualified name get deployed. Thus you can not share code, because as it is specified in the documentation, the module folder becomes the root of the zip of the function.\r\n\r\nCurrently there is a workaround that people are using the vendor option if only one folder is shared, but this approach does not work for multiple folders\r\n\r\n### Proposed solution (optional)\r\n\r\nSo a general idea would be to combine the zip named as the fully qualified function name and the zip named as the function excluding the folder named as the module. But here there could be an issue if there would be no patterns supplied in the root package field.\r\n\r\nSo I would propose that the merging/copying would only happen if there are patterns defined in the root package field and also including an extra field in custom pythonRequirements or maybe inside the function definitions, something along the lines of includeNonModuleFiles to ensure no breaking changes.\r\n\r\nI'm wondering if this is possible or if there are any issues with this approach? Have not looked at the code yet, so no idea if my approach would be feasible. Also is this a use case that this plugin would even want to support?","author":{"url":"https://github.com/markonose","@type":"Person","name":"markonose"},"datePublished":"2023-04-21T11:46:07Z","url":"https://github.com/serverless/serverless-python-requirements/issues/767"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:366eaff8-2161-ce03-131a-7a3766bafa17 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C708:21169F:4ED69:687D5:6B04301B |
| html-safe-nonce | d2ce083efd16ad95f25e62af9c88b4784d319eb5d7ee0b3c75df84ca6f821691 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzA4OjIxMTY5Rjo0RUQ2OTo2ODdENTo2QjA0MzAxQiIsInZpc2l0b3JfaWQiOiIxOTczMzYwNjQxOTEzOTI1NjU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e6ef00fa1ffe3b5215f15fd4d195bb24d2feefb60e150bcf6463dedaa1a77d6a |
| hovercard-subject-tag | issue:1678388909 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/serverless/serverless-python-requirements/767/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bd875232d9a26339e10cac13f342bc8e0ce18e6b00d46b20599a0fa06191275f/serverless/serverless-python-requirements/issues/767 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bd875232d9a26339e10cac13f342bc8e0ce18e6b00d46b20599a0fa06191275f/serverless/serverless-python-requirements/issues/767 |
| og:image:alt | Is there an existing issue for this? I have searched existing issues, it hasn't been reported yet Use case description See: #734 Besides it being a bug report, it describes the use case, also see: ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | markonose |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| turbo-cache-control | no-preview |
| go-import | github.com/serverless/serverless-python-requirements git https://github.com/serverless/serverless-python-requirements.git |
| octolytics-dimension-user_id | 13742415 |
| octolytics-dimension-user_login | serverless |
| octolytics-dimension-repository_id | 76508594 |
| octolytics-dimension-repository_nwo | serverless/serverless-python-requirements |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 76508594 |
| octolytics-dimension-repository_network_root_nwo | serverless/serverless-python-requirements |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width