Skip to content
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

slim_handler option broken #1342

Open
mggevaer opened this issue Jul 19, 2024 · 5 comments
Open

slim_handler option broken #1342

mggevaer opened this issue Jul 19, 2024 · 5 comments

Comments

@mggevaer
Copy link

mggevaer commented Jul 19, 2024

Context

Unable to deploy or update a very simple hello_world Flask application when slim_handler is enabled. This has been a real pain since I have a single dependency that is >250mb, so I can't put it into a separate layer either.

Expected Behavior

slim_handler should not prevent deployment.

Actual Behavior

Following output is shown, I modified the paths for privacy reasons.

3d-platform\test-backend> zappa update dev
Calling update for stage dev..
Downloading and installing dependencies..
INFO: - markupsafe==2.1.5: Using locally cached manylinux wheel
INFO: - pyyaml==6.0.1: Using locally cached manylinux wheel
INFO: - charset-normalizer==3.3.2: Using locally cached manylinux wheel
Packaging project as gzipped tarball.
ERROR: To modify pip, please run the following command:
C:\test-backend\test-backend\.venv\Scripts\python.exe -m pip install --quiet --target C:\test-backend\test-backend\handler_venv\Lib\site-packages zappa==0.59.0 toml==0.10.2 cfn-flip==1.3.0 werkzeug==3.0.3 idna==3.7 troposphere==4.8.1 
boto3==1.34.145 six==1.16.0 click==8.1.7 requests==2.32.3 python-dateutil==2.9.0.post0 urllib3==2.2.2 durationpy==0.7 pip==24.0 PyYAML==6.0.1 MarkupSafe==2.1.5 s3transfer==0.10.2 argcomplete==3.4.0 wheel==0.43.0 tqdm==4.66.4 text-unidecode==1.3 jmespath==1.0.1 charset-normalizer==3.3.2 botocore==1.34.145 placebo==0.9.0 hjson==3.1.0 python-slugify==8.0.4 certifi==2024.7.4 kappa==0.6.0 colorama==0.4.6 setuptools

[notice] A new release of pip is available: 24.0 -> 24.1.2
[notice] To update, run: python.exe -m pip install --upgrade pip    
INFO:command: pip install --quiet --target C:\test-backend\test-backend\handler_venv\Lib\site-packages zappa==0.59.0 toml==0.10.2 cfn-flip==1.3.0 werkzeug==3.0.3 idna==3.7 troposphere==4.8.1 boto3==1.34.145 six==1.16.0 
click==8.1.7 requests==2.32.3 python-dateutil==2.9.0.post0 urllib3==2.2.2 durationpy==0.7 pip==24.0 PyYAML==6.0.1 MarkupSafe==2.1.5 s3transfer==0.10.2 argcomplete==3.4.0 wheel==0.43.0 tqdm==4.66.4 text-unidecode==1.3 jmespath==1.0.1 charset-normalizer==3.3.2 botocore==1.34.145 placebo==0.9.0 hjson==3.1.0 python-slugify==8.0.4 certifi==2024.7.4 kappa==0.6.0 colorama==0.4.6 setuptools
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "C:\test-backend\test-backend\.venv\Lib\site-packages\zappa\cli.py", line 3048, in handle
    sys.exit(cli.handle())
             ^^^^^^^^^^^^
  File "C:\test-backend\test-backend\.venv\Lib\site-packages\zappa\cli.py", line 521, in handle
    self.dispatch_command(self.command, stage)
  File "C:\test-backend\test-backend\.venv\Lib\site-packages\zappa\cli.py", line 574, in dispatch_command
    self.update(
  File "C:\test-backend\test-backend\.venv\Lib\site-packages\zappa\cli.py", line 980, in update
    self.create_package()
  File "C:\test-backend\test-backend\.venv\Lib\site-packages\zappa\cli.py", line 2441, in create_package
    venv=self.zappa.create_handler_venv(use_zappa_release=use_zappa_release),  # type: ignore[attr-defined]
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\test-backend\test-backend\.venv\Lib\site-packages\zappa\core.py", line 494, in create_handler_venv
    if stderror_result.strip():
       ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'strip'

==============

Need help? Found a bug? Let us know! :D
File bug reports on GitHub here: https://github.com/Zappa/Zappa
And join our Slack channel here: https://zappateam.slack.com
Love!,
 ~ Team Zappa!

Possible Fix

Steps to Reproduce

  1. Create a new empty folder
  2. Create a very simple Flask application using the Flask Quickstart guide
    1. create a virtualenv. using py -3 -m venv .venv
    2. activate using .venv\Scripts\activate
    3. run pip install Flask
    4. create a file named main.py containing the code from https://flask.palletsprojects.com/en/3.0.x/quickstart/
    5. run flask --app main run to verify the simple hello world runs locally.
  3. Install zappa by running pip install Zappa within the virtualenv.
  4. Deploy the application using zappa deploy dev. This should work as expected.
  5. Add the line "slim_handler": true
  6. Run zappa update dev, the update should now fail.

Your Environment

  • Zappa version used: 0.59.0
  • Operating System and Python version: windows 10, python 3.12
  • The output of pip freeze:
argcomplete==3.4.0
blinker==1.8.2
boto3==1.34.145
botocore==1.34.145
certifi==2024.7.4
cfn-flip==1.3.0
charset-normalizer==3.3.2   
click==8.1.7
colorama==0.4.6
durationpy==0.7
Flask==3.0.3
hjson==3.1.0
idna==3.7
itsdangerous==2.2.0
Jinja2==3.1.4
jmespath==1.0.1
kappa==0.6.0
MarkupSafe==2.1.5
placebo==0.9.0
python-dateutil==2.9.0.post0
python-slugify==8.0.4       
PyYAML==6.0.1
requests==2.32.3
s3transfer==0.10.2
setuptools==71.0.3
six==1.16.0
text-unidecode==1.3
toml==0.10.2
tqdm==4.66.4
troposphere==4.8.1
urllib3==2.2.2
Werkzeug==3.0.3
wheel==0.43.0
zappa==0.59.0
  • Link to your project (optional):
  • Your zappa_settings.json:
{
    "dev": {
        "app_function": "main.app",
        "aws_region": "eu-west-1",
        "exclude": [
            "boto3",
            "dateutil",
            "botocore",
            "s3transfer",
            "concurrent"
        ],
        "profile_name": "default",
        "project_name": "test-backend",
        "runtime": "python3.12",
        "s3_bucket": "zappa-test-should-be-destroyed",
        "slim_handler": true
    }
}
@Maxiron
Copy link

Maxiron commented Aug 7, 2024

I keep encountering this same issue when trying to deploy a django project. How did you fix yours if it was fixed

@mggevaer
Copy link
Author

@Maxiron I ended up running my application in Docker.
https://ianwhitestone.work/zappa-serverless-docker/

@Maxiron
Copy link

Maxiron commented Aug 11, 2024

@Maxiron I ended up running my application in Docker.
https://ianwhitestone.work/zappa-serverless-docker/

Thank you

@ml3477
Copy link

ml3477 commented Aug 29, 2024

This issue seems to be on Windows machines only, I can replicate on Windows 11 / Python 3.12. Setting slim_handler to False or using MacOS solves the issue.

Turns out it's been a very long running issue #2145

@pnaik07
Copy link

pnaik07 commented Sep 15, 2024

Sigh! Wasted so much time to fix it. Turns out to be a windows issue. Any fix on this yet?

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

No branches or pull requests

4 participants