Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/422-update-exclude-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
monkut authored Aug 16, 2022
2 parents 18dd896 + fff5ed8 commit 7328958
Show file tree
Hide file tree
Showing 41 changed files with 1,082 additions and 2,074 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--- Provide a general summary of the issue in the Title above -->
## Context
<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
<!--- Also, please make sure that you are running Zappa _from a virtual environment_ and are using Python 3.6/3.7/3.8 -->
<!--- Also, please make sure that you are running Zappa _from a virtual environment_ and are using Python 3.7/3.8/3.9 -->

## Expected Behavior
<!--- Tell us what should happen -->
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Before you submit this PR, please make sure that you meet these criteria:
* Did you **make sure this code actually works on Lambda**, as well as locally?
* Did you test this code with all of **Python 3.6**, **Python 3.7** and **Python 3.8** ?
* Did you test this code with all of **Python 3.7**, **Python 3.8** and **Python 3.9** ?
* Does this commit ONLY relate to the issue at hand and have your linter shit all over the code?
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CD

on: # yamllint disable-line rule:truthy
# From documentation:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore
# on.push.tags: If you define only tags/tags-ignore or only branches/branches-ignore, the workflow won't run for events affecting the undefined Git ref.
#
# This workflow will only run when a tag matching the criteria is pushed
push:
tags: ["v?[0-9]+.[0-9]+.[0-9]+"]

jobs:
publish:
runs-on: ubuntu-20.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install `pypa/build`
run: python -m pip install build
- name: Build sdist and wheel
run: python -m build --sdist --wheel --outdir ./dist/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
27 changes: 24 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ name: CI
on: # yamllint disable-line rule:truthy
pull_request:
branches: ["master"]
push:
branches: ["master"]

jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
python: [3.6, 3.7, 3.8]
python: [3.7, 3.8, 3.9]
steps:
- name: Checkout Code Repository
uses: actions/checkout@v2
Expand All @@ -20,13 +22,32 @@ jobs:
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip${{ matrix.python }}-${{ hashFiles('requirements.txt') }}
key: ${{ runner.os }}-pip${{ matrix.python }}-${{ hashFiles('Pipfile') }}
restore-keys: ${{ runner.os }}-pip${{ matrix.python }}-
- name: make sure we have version tags
run: git fetch --unshallow --tags
- name: Setup Virtualenv
run: python -m venv .venv
- name: Install
run: source .venv/bin/activate && make requirements && python setup.py install
- name: Lint
run: source .venv/bin/activate && make flake black-check
run: source .venv/bin/activate && make flake black-check isort-check
- name: Test
run: source .venv/bin/activate && make tests
- name: Upload Coverage
run: .venv/bin/coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: py${{ matrix.python }}
COVERALLS_PARALLEL: true

coverage:
needs: test
runs-on: ubuntu-20.04
steps:
- name: Set up Python
uses: actions/setup-python@v2
- name: Finalise Coverage
run: pip3 install --upgrade coveralls && coveralls --service=github --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*~
*.zip
Pipfile.lock

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
32 changes: 30 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
# Zappa Changelog

## 0.53.0
## 0.55.0
* Fix "cd workflow fired event outside of the create tags event" (#1152)
* Remove 'futures' package requirement (#826,#808)
* Remove function invoke command does not need quotes around function (#900)
* Add python_requires to setup.py (#1111)
* Remove python 3.6 support (#1151)
* Update handler to be global if INSTANTIATE_LAMBDA_HANDLER_ON_IMPORT=True (#1096)
* Fix async invocation in Python 3 (#1006)
* Drastically reduce cold start times by calling LambdaHandler externally (#982)
* Support Newest Manylinux Version for dependencies (#1083)
* Decode zappa invoke output regardless of --no-color option (#1069)
* Convert project to using 'pipenv' to manage dependencies (#1077)
* Ensure unique scheduled event names (#1080)
* Check isort in CI (#1078)
* Use 'black' everywhere (#1076)
* Update setup.py (#1050)

## 0.54.2
* Update documentation to reflect python 3.9 support (#1137)

## 0.54.1
* Increase Lambda client read timeout to 15m (#1065)
* Unpin `Werkzeug` from `v0.x` (#1067)

## 0.54.0
* Pin troposphere version and update to 3.x (#1029)
* Relax stage name restrictions when not using apigateway (#993)
* Wait for lambda to become active during deploy/update (#992)
* add support for Python 3.9 (#1026)

## 0.53.0
* Deprecated ACME v1 for Lets Encrypt
* Global black formatting
* Update & deploy using a docker container
* See [blog post](https://ianwhitestone.work/zappa-serverless-docker/) for more details on the current functionality and how it works
* See [PR](https://github.com/zappa/Zappa/pull/967) or [original issue](https://github.com/Miserlou/Zappa/issues/2188) for discussion around what is currently supported & next steps


## 0.52.0
* Remove dateutil version restriction
* Fix failed downloads of wheel packages with non-alphanumeric characters
Expand Down
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ clean:
rm -f .coverage

requirements:
./requirements.sh
pip install -r requirements.txt
pip install -r test_requirements.txt
pip install pipenv>2021.11.15
pipenv lock
pipenv sync --dev

build: clean requirements-install
python setup.py sdist
Expand All @@ -39,18 +39,21 @@ mypy:
mypy --show-error-codes --pretty --ignore-missing-imports --strict zappa tests

black:
black zappa tests
black --line-length 127 .

black-check:
black zappa tests --check
black --line-length 127 . --check
@echo "If this fails, simply run: make black"

isort:
isort --recursive .
isort . --profile=black

isort-check:
isort --check . --profile=black

flake:
flake8 zappa --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 zappa --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 zappa --count --exit-zero --max-complexity=55 --max-line-length=127 --statistics --ignore F403,F405,E203,E231,E252,W503

test-docs:
nosetests tests/tests_docs.py --with-coverage --cover-package=zappa --with-timer
Expand Down
48 changes: 48 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
black = "*"
boto3-stubs = "*"
coveralls = "*"
Django = "<4"
django-stubs = "*"
flake8 = "*"
Flask = "*"
isort = "*"
mock = "*"
mypy = "*"
nose = "*"
nose-timer = "*"
pipenv = ">2021.11.15"
packaging = "*"

[packages]
argcomplete = "*"
boto3 = ">=1.17.28"
durationpy = "*"
hjson = "*"
jmespath = "*"
kappa = "==0.6.0"
pip = ">=9.0.1"
# Workaround until tests are updated to work with 'placebo' 0.10
# Move to 'dev-packages' when unpinned
placebo = "<0.10"
python-dateutil = "*"
python-slugify = "*"
PyYAML = "*"
# previous versions don't work with urllib3 1.24
requests = ">=2.20.0"
six = "*"
toml = "*"
tqdm = "*"
troposphere = ">=3.0"
Werkzeug = "*"
wheel = "*"
wsgi-request-logger = "*"

[pipenv]
# Required for 'black' since all of its release tags contain 'b'
allow_prereleases = true
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Zappa - Serverless Python

[![Build Status](https://travis-ci.org/zappa/Zappa.svg)](https://travis-ci.org/zappa/Zappa)
[![CI](https://github.com/zappa/Zappa/actions/workflows/ci.yaml/badge.svg?branch=master&event=push)](https://github.com/zappa/Zappa/actions/workflows/ci.yaml)
[![Coverage](https://img.shields.io/coveralls/zappa/Zappa.svg)](https://coveralls.io/github/zappa/Zappa)
[![PyPI](https://img.shields.io/pypi/v/Zappa.svg)](https://pypi.python.org/pypi/zappa)
[![Slack](https://img.shields.io/badge/chat-slack-ff69b4.svg)](https://zappateam.slack.com/)
Expand Down Expand Up @@ -79,6 +79,7 @@
- [Application Load Balancer Event Source](#application-load-balancer-event-source)
- [Endpoint Configuration](#endpoint-configuration)
- [Example Private API Gateway configuration](#example-private-api-gateway-configuration)
- [Cold Starts (Experimental)](#cold-starts-experimental)
- [Zappa Guides](#zappa-guides)
- [Zappa in the Press](#zappa-in-the-press)
- [Sites Using Zappa](#sites-using-zappa)
Expand Down Expand Up @@ -134,7 +135,7 @@ __Awesome!__

## Installation and Configuration

_Before you begin, make sure you are running Python 3.6/3.7/3.8 and you have a valid AWS account and your [AWS credentials file](https://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs) is properly installed._
_Before you begin, make sure you are running Python 3.7/3.8/3.9 and you have a valid AWS account and your [AWS credentials file](https://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs) is properly installed._

**Zappa** can easily be installed through pip, like so:

Expand Down Expand Up @@ -393,11 +394,11 @@ You can execute any function in your application directly at any time by using t

For instance, suppose you have a basic application in a file called "my_app.py", and you want to invoke a function in it called "my_function". Once your application is deployed, you can invoke that function at any time by calling:

$ zappa invoke production 'my_app.my_function'
$ zappa invoke production my_app.my_function

Any remote print statements made and the value the function returned will then be printed to your local console. **Nifty!**

You can also invoke interpretable Python 3.6/3.7/3.8 strings directly by using `--raw`, like so:
You can also invoke interpretable Python 3.7/3.8/3.9 strings directly by using `--raw`, like so:

$ zappa invoke production "print(1 + 2 + 3)" --raw

Expand All @@ -420,8 +421,6 @@ Commands which require direct user input, such as `createsuperuser`, should be [

For more Django integration, take a look at the [zappa-django-utils](https://github.com/Miserlou/zappa-django-utils) project.

_(Please note that commands which take over 30 seconds to execute may time-out preventing output from being returned - but the command may continue to run. See [this related issue](https://github.com/Miserlou/Zappa/issues/205#issuecomment-236391248) for a work-around.)_

### SSL Certification

Zappa can be deployed to custom domain names and subdomains with custom SSL certificates, Let's Encrypt certificates, and [AWS Certificate Manager](https://aws.amazon.com/certificate-manager/) (ACM) certificates.
Expand Down Expand Up @@ -931,7 +930,7 @@ to change Zappa's behavior. Use these at your own risk!
"role_name": "MyLambdaRole", // Name of Zappa execution role. Default <project_name>-<env>-ZappaExecutionRole. To use a different, pre-existing policy, you must also set manage_roles to false.
"role_arn": "arn:aws:iam::12345:role/app-ZappaLambdaExecutionRole", // ARN of Zappa execution role. Default to None. To use a different, pre-existing policy, you must also set manage_roles to false. This overrides role_name. Use with temporary credentials via GetFederationToken.
"route53_enabled": true, // Have Zappa update your Route53 Hosted Zones when certifying with a custom domain. Default true.
"runtime": "python3.6", // Python runtime to use on Lambda. Can be one of "python3.6", "python3.7" or "python3.8". Defaults to whatever the current Python being used is.
"runtime": "python3.9", // Python runtime to use on Lambda. Can be one of "python3.7", "python3.8", or "python3.9". Defaults to whatever the current Python being used is.
"s3_bucket": "dev-bucket", // Zappa zip bucket,
"slim_handler": false, // Useful if project >50M. Set true to just upload a small handler to Lambda and load actual project from S3 at runtime. Default false.
"settings_file": "~/Projects/MyApp/settings/dev_settings.py", // Server side settings file location,
Expand Down Expand Up @@ -1446,6 +1445,10 @@ apigateway_resource_policy.json:
}
```

### Cold Starts (Experimental)

Lambda may provide additional resources than provisioned during cold start initialization. Set `INSTANTIATE_LAMBDA_HANDLER_ON_IMPORT=True` to instantiate the lambda handler on import. This is an experimental feature - if startup time is critical, look into using Provisioned Concurrency.

## Zappa Guides

* [Django-Zappa tutorial (screencast)](https://www.youtube.com/watch?v=plUrbPN0xc8&feature=youtu.be).
Expand Down Expand Up @@ -1536,6 +1539,7 @@ If you are adding a non-trivial amount of new code, please include a functioning
Please include the GitHub issue or pull request URL that has discussion related to your changes as a comment in the code ([example](https://github.com/zappa/Zappa/blob/fae2925431b820eaedf088a632022e4120a29f89/zappa/zappa.py#L241-L243)). This greatly helps for project maintainability, as it allows us to trace back use cases and explain decision making. Similarly, please make sure that you meet all of the requirements listed in the [pull request template](https://raw.githubusercontent.com/zappa/Zappa/master/.github/PULL_REQUEST_TEMPLATE.md).

Please feel free to work on any open ticket, especially any ticket marked with the "help-wanted" label. If you get stuck or want to discuss an issue further, please join [our Slack channel](https://zappateam.slack.com/), where you'll find a community of smart and interesting people working dilligently on hard problems.
[Zappa Slack Auto Invite](https://slackautoinviter.herokuapp.com)

Zappa does not intend to conform to PEP8, isolate your commits so that changes to functionality with changes made by your linter.

Expand Down
11 changes: 7 additions & 4 deletions example/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import logging

from flask import Flask

app = Flask(__name__)
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

@app.route('/', methods=['GET', 'POST'])

@app.route("/", methods=["GET", "POST"])
def lambda_handler(event=None, context=None):
logger.info('Lambda function invoked index()')
logger.info("Lambda function invoked index()")

return "Flask says Hello!!"

return 'Flask says Hello!!'

if __name__ == '__main__':
if __name__ == "__main__":
app.run(debug=True)
Loading

0 comments on commit 7328958

Please sign in to comment.