-
Notifications
You must be signed in to change notification settings - Fork 178
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
Careful with Mac deployment on Lambda #241
Comments
what does the do something like |
Thank you so much for the tip on using I wonder if perhaps you could go into Lambda and export your function's deployment ZIP for me, and host that somewhere where I could download it? That might be the fastest path to fruition at this point, as I feel like I've thrown everything and the kitchen sink at this problem, trying to get it to work. Plus I'd like to compare your presumably-working deployment package with my own. So here's a not-so-quick history of what I've tried... First I wanted to make things easier and use a deterministic build tool like pipenv to handle the installation of packages and virtual environment management. However that uses PIP 10 internally, and it seems both Flask and Flask-Ask (the current versions in PyPI anyway) won't work with PIP 10 because of their own buggy code. I checked the Flask-Ask repo and saw that they already have bugfixes committed for PIP 10 issues, but who knows how long it will be before those changes make their way to a release and then the new release versions percolate up to projects like Zappa. So instead I went with virtualenvwrapper to create my venv, and then downgraded to pip 9.0.1 once inside. This seemed to work but I had still had problems getting Flask and Flask-Ask to install correctly. When I ran my
I saw an issue on the Zappa Github that others were getting this same error as well. So I tried all of their suggestions - which involved using different requirements.txt files or even different versions of Python. For instance I tried doing it with Python 2.7 but that failed too - I don't remember the specific problem but I know it failed. And that was on my my Windows machine, running Ubuntu WSL. The WSL version also had troubles because it doesn't have python3-dev so it can't install Python-Levenshtein. So eventually I switched over to my Mac. On the Mac I encountered a variety of other headaches... first I couldn't get Homebrew to link Python correctly (you have to add sbin to the PATH), then I had to downgrade from Python 3.7 to 3.6 (since 3.7 is the current version which is not yet supported by zappa). Finally, miraculously, I was able to get everything deployed through Zappa without the 502 complaint. It even said "Your updated zappa deployment is live!" Unfortunately this was a lie. This is where I encountered another error. When I go to the deployed URL I get the same TypeError: 'NoneType' object is not callable. But for a different reason than before. Before I believe it had something to do with zappa not bundling Flask and Flask-Ask in the deployment package. But now when I do zappa tail I see this error:
I Googled for that error and an issue came up which implies I'm missing an optional dependency. But their solution (installing python-levenshtein) doesn't work because pip just says it's already installed. I am pretty much at my wit's end right now trying and repeatedly failing to get this to work. Which is why I'm wondering if comparing the ZIP deployment packages might shed some light. Also any info about your system (were you on a Mac? Windows? Linux?) when you deployed your copy would be helpful too. |
Oh and one last thing - what on Earth should I be setting the ANDROID_ID environment variable to? I don't have any Android devices. |
I was on WSL. why dont you use virtualenv with python3-dev on WSL. Mine was 3.6.4 if I recall, but that shouldn't matter. Source the env and install the requirements.txt dependencies from the root of the project. That worked. There is also a comment from @digitald on the original PR that implemented these changes. |
The ANDROID_ID is the only current workaround I have for using this on a PAAS such as AWS Lambda |
If you login using the example code for the Mobileclient class in gmusicapi and use the function get_registered_devices, you can be a Guinea pig for the rest of the non android users. If you dont use the android I'd, though, eventually your shit is gonna be blocked by google. They need a valid device id in order to validate the context of the request, or at least that is how I understand it |
First of all, afaik there isn't a way to install python3-dev on WSL - not the 3.6 version anyway. WSL comes with Python 3.5 which isn't sufficient for zappa; you have to use the third party ppa:jonathonf/python-3.6 apt repo to install it and even then it's just python -- not python3-dev. If there is some other way to install the 3.6 version of python3-dev on WSL please let me know! Because I haven't found any. Secondly, I confess I don't know what you mean when you say "source the env" - forgive my ignore but I just don't know that nomenclature. Third, I tried running I also tried @digiltd 's suggestion (from that other PR you mentioned) of moving around the cryptography/pycrypto files from the lambda_packages folder, but in the end this didn't make a difference. I still get the same Cryptodome error when I run zappa tail. So I'd like to ask once again, can you go into your Lambda function, hit Actions > Export Function, click Download Deployment Package, and share that ZIP file somewhere? You'd probably want to then remove the zappa_settings.json from the file and re-zip if you're worried about env vars. Thank you in advance. |
I actually lied to you. Its python3.6-dev |
My python version is 3.6.3 |
Holy crap I think I got it working. And side note: wow - given how many headaches I encountered along the way, this Zappa solution really isn't ready for primetime yet. It occurred to me that if my remaining problems were Mac-specific, I could just try doing this whole Zappa deploy process from inside a Docker container, thereby effectively from within Linux, and just copy all my files there and run all the Python commands there too, as if the container were my build machine. Once I did that it seems like I got past all the errors I was having. Still had to downgrade the pip version once inside the venv of course. At first I got a invalid device ID in Zappa tail, but saw it suggested I use some generated device ID (that starts with the string "ios")... and I am very relieved to report that has actually been working! (so far) |
This is immaterial at this point but I can't find python3.6-dev in any of the WSL repos. Did you have to add a custom one? |
Can you send me what you're zappa settings json looks like? Maybe redact the private stuff, but use redacted1, redacted2, etc... for things that are the same, but redacted. |
Yeah @soapergem the problems with your deployment i think is more Lambda with Mac related than Zappa related. There are some conflicts between Lambda python packages and Mac python packages. For a few of them atleast if i remember correctly. |
I found a link that is a tutorial for setting up a docker container with the same environment as the Lambda function: https://blog.zappa.io/posts/simplified-aws-lambda-deployments-with-docker-and-zappa @soapergem do you think you'd be able to try this after I get it working in my environment? I think this would be the ultimate breakthrough to making the Lambda deployment as streamlined as possible. |
@fergyfresh in effect I already have. His mcrowson/zappa-builder container is an extension of the lambci/lambda Docker container which has every different runtime under the sun. When I used Docker on my Mac to do the Zappa deploy I made a simple image based on python:3.6-stretch instead. But in just about every way it was functionally the same to exactly what he's outlined in the guide you linked. Even down to passing in the AWS access environment variables. So without even looking I can tell you that yes, it would work, as I've already done it - just with a slightly different base container. As far as making this easy for others to run, we of course can't add a new Dockerfile definition to the existing repo as it would conflict with the one there now, but I could modify his docker run line to be the appropriate one to run here. In fact I'll make a short PR to the Readme file sometime this week to set that up. In other news, remember how you said I could be the guinea pig for the non-Android users? Well long story short it isn't working - I'm seeing some forbidden errors. With my iOS device ID in place I can run commands like "ask gee music to play songs by Taylor swift" and it even shows the album art in the Alexa Test Console, but it then fails to actually play anything. Apparently getting the media URLs are returning Forbidden errors. So I think I'm going to have to get my hands on a friend's Android device, although I was hoping we could build out more documentation about what needs to be done there to get an Android ID. Having not used Android at all I don't really know where to start. |
As for the docker stuff, thanks so much for clarifying. I didn't know if you went the docker route or the manually swapping out the python packages like @digiltd did. As for the iOS device ID stuff, I'm sorry to hear that. The issue resides in the fact that about 6 months ago Google Play Services changed their OAuth scheme to require a device ID that is generated as a result of your MAC address on your device with some special sauce (for Android phones). Without knowing the differences between the special sauce in Android vs. iOS and having none of the maintainers of Is there any context around the 'forbidden' errors. Also I believe a user from Eastern Europe was able to get this working using iOS I believe. Basically the device ID for android is |
Is anyone still following this issue? I think I have a fix for this that I wanna try tommorrow. It revolves around using a docker container to |
I'm trying to get this deployed to Lambda/API Gateway using Zappa as outlined in the readme. However, everytime I call
zappa deploy dev
(orzappa update dev
) it gives me the following error about API Gateway:Also, if I try going to the API Gateway URL directly I just see this:
Tagging @fergyfresh since I believe he was the one who did the Zappa integration.
The text was updated successfully, but these errors were encountered: