-
-
Notifications
You must be signed in to change notification settings - Fork 590
Package version mechanism incompatible with AWS Lambda #584
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
Comments
Hi. If lambda doesn't actually install the packages, that indeed wouldn't be a supported configuration. |
I don't know how it works on Azure or other serverless Cloud providers, but in AWS Lambda all third-party packages are just zipped together with your code and sent to Amazon servers. Following files are from my project and exists in repository:
And these are third-parties, normally installed through
|
Hi @danie1k , I also had the same error. In my case it was because I enabled slim mode in serverless configuration. Disabling the slim mode in serverless config fixed it for me. Hope it helps! |
Yeah I'd say overall this is something that has to be handled within AWS, with however they manage to support "normal" package installations. @harshavardhangsv thanks for chiming in with the specific suggestion on what to tweak there! Going to close this, but if any others have this issue (or have suggestions for what's needed on the AWS side) I'm sure others finding this will appreciate it. |
@harshavardhangsv thanks for the tip! But... Parameter
@Julian With More information on |
I don't think is as uncommon as you're making it out to be, jsonschema uses the same "style" of versioning as it always has (and over the past major version all that happened was switching from one tool that did so to another, setuptools-scm, a PyPA "official" way to do so even). I of course want things to work for as many users as possible, but AWS is doing nonstandard things here -- so if anything I look at it in the reverse -- should one single relatively uncommon platform (AWS Lambda) cause any package looking to do Python versioning in "modern" ways (modern being like literally available for the past 5 years :) or should Lambda just fix itself (or use other configurations of it) -- e.g., if all slim does is ship source code directly, why not instead ship the output of |
Disabling slim mode did not change anything for me, i'm still getting "The 'jsonschema' distribution was not found and is required by the application". |
Hard to help without seeing what commands you (or Amazon) runs to install the package, and what output it produced. |
From deployment instructions in AWS docs I can only assume nothing is "installed". EDIT: everything works fine with 2.6.0. |
Can you please add a note to the front page of the documentation that this library is not Lambda-compatible? I just threw a few hours down the drain that could have easily been avoided were this prominently noted. Also, on a side-note, labeling Lambda an "uncommon" platform is perhaps a bit out-of-touch. My current project is about 90% lambda code vs traditional server instances and I don't believe my approach is unusual. In any case, breaking backwards-compatibility without a really good reason is always a bad idea. For my own use, I've pinned this package to 3.0.2 and I guess I will be forced to maintain a fork going forward. |
@cwells AWS Lambda was never supported by this library. The only supported platforms are those that run under CI. |
@Julian It may have not been supported, but it worked. My point is that it no longer works, and it's unclear to me what tangible benefit was obtained by the change that broke it. You may not have planned on having lambda support, but you got it for free. Why throw it away? |
@cwells The change which broke this was a migration from Rather than maintaining a fork, your energy would probably be better spent contributing upstream fixes to those libraries to make them compatible with Lambda - or, better yet, asking the Lambda Python team to engage more actively with the packaging community and developing tooling integration that works with Python's evolving PEP-specified toolchain that solves a whole bunch of problems for tons of other platforms, rather than mandating the somewhat odd "installed but not installed" artifact shape for Python which creates lots of these problems. I'm mostly familiar with the problems rather than the solutions in this space (which is why I avoid lambda) but it looks like there are others actively engaged with this problem, for example maybe the right place for the fix to land is in https://pypi.org/project/lambda-setuptools/ . |
@glyph If I had time to contribute, I would concur. Unfortunately I'm engaged in developing a startup where I am the only developer, so I don't have the resources to commit to any of the above. This is doubly true since Python packaging isn't an area I have any particular expertise in. I selected this library at a time it was compatible, only to have it break underneath of me during an update. I'm certainly willing to file a bug report with AWS and will do so, but at this time, a fork appears to be the least time-consuming option, since cherry-picking commits to the library is much more straightforward than diving into the mess that is Python packaging. I'd also add that of the Python libraries I utilize (which are numerous), this is the only one to cause any sort of problem, hence my skepticism about the value of the change. |
I can sympathize with these sentiments. Based on my understanding of the Lambda & Python Packaging ecosystems, unless something changes to make them work together more smoothly, I would expect to see this sort of breakage propagate through more libraries as people adopt more modern packaging standards. (Probably if you just ignore it, eventually someone on either the Lambda or the open source side will fix it, since the platform will get less and less useful if lots of libraries start breaking it.) |
I did a little reading last night, and came across this comment in setuptools-scm: pypa/setuptools-scm#143 (comment) setuptools-scm doesn't appear particularly well-documented, but it seems it has some options for writing out the version to the filesystem during installation rather than doing it dynamically at runtime. Maybe this would be a solution? It seems calculating a static value at runtime isn't terribly efficient anyway. I'd love to test this, but it's unclear where I would add this setting as there is no setup.py =( |
Ok, it seems we were barking up the wrong tree. The problem stems from the Changing my serverless.yml to the following appears to work:
Kudos to @glyph for shaming me into a bit more effort. |
@Julian Perhaps a blurb can be added to the docs related to deploying this library using Serverless? If deploying with Serverless framework, ensure that pythonRequirements:
dockerizePip: non-linux
useDownloadCache: false
useStaticCache: false
slim: true
slimPatternsAppendDefaults: false
slimPatterns:
- '**/*.py[c|o]'
- '**/__pycache__*' Otherwise you be unable to import the library. By default, the |
Happy to see that added (maybe to the FAQ?)! |
Sorry, going to have to rescind that. Editing rst is apparently not something vscode does well (no plugin was able to render a preview of the faq) and I'm not willing to go down that rabbit hole. I haven't used rst in years for a reason =P |
Make necessary packaging tweaks (taken from the discussion at python-jsonschema/jsonschema#584) to make the `jsonschema` package work when running in AWS Lambda.
b3c8672a3 Merge pull request #587 from json-schema-org/cross-draft-tests e2a681ac6 $comment -> comment 52eb27902 add draft 2020-12 -> draft 2019-09 test c4ed16dfe add draft 2019-09 -> draft 7 test 3df4712a9 add draft 2019-09 -> draft 2020-12 test dab94face add draft 7 -> draft 2019-09 test dfcea626f Merge pull request #584 from json-schema-org/doi e4a59d962 Add a badge for a Zenodo DOI. git-subtree-dir: json git-subtree-split: b3c8672a3fa0a0691124e455680b34d5512cae94
Tested on AWS Lambda. Following code does not work on AWS Lambda due to lack of package manager.
https://github.com/Julian/jsonschema/blob/e4fa34f6517895a81e5ba7e648dc0796f25f9b21/jsonschema/__init__.py#L32-L33
It has beed added in b07d0f1 commit.
Stacktrace I'm getting
The text was updated successfully, but these errors were encountered: