Skip to content

DONT MERGE #1471

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

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
efc02f3
Http Proxy Support
YunchuWang Nov 9, 2023
9922b2c
final changes and tests
YunchuWang Apr 5, 2024
56d5a81
Merge branch 'dev' into wangbill/http_v2
YunchuWang Apr 5, 2024
dffc81f
fix ppl
YunchuWang Apr 5, 2024
f67698e
Merge branch 'wangbill/http_v2' of https://github.com/Azure/azure-fun…
YunchuWang Apr 5, 2024
fa52c76
revert
YunchuWang Apr 5, 2024
de028b6
fix
YunchuWang Apr 5, 2024
d5987cf
fix
YunchuWang Apr 5, 2024
2410771
fix
YunchuWang Apr 5, 2024
b78e549
fix
YunchuWang Apr 5, 2024
58e89f0
flake8
YunchuWang Apr 5, 2024
0883bb8
flake8
YunchuWang Apr 5, 2024
54bd579
flake8
YunchuWang Apr 5, 2024
e0c1308
Merge branch 'dev' into wangbill/http_v2
YunchuWang Apr 5, 2024
eb26157
only run for 3.8+
YunchuWang Apr 5, 2024
e047506
Merge https://github.com/Azure/azure-functions-python-worker into wan…
YunchuWang Apr 5, 2024
83b69c7
Merge branch 'wangbill/http_v2' of https://github.com/Azure/azure-fun…
YunchuWang Apr 5, 2024
2b99faa
FIX
YunchuWang Apr 5, 2024
5d25510
skip tests for 3.7-
YunchuWang Apr 5, 2024
4cea83a
fix
YunchuWang Apr 5, 2024
a9414d8
fix
YunchuWang Apr 5, 2024
e20b8bb
fix
YunchuWang Apr 5, 2024
64d9e18
fix
YunchuWang Apr 5, 2024
f1c780a
fix styles
YunchuWang Apr 6, 2024
bb8e77a
fix
YunchuWang Apr 6, 2024
1e66de6
s
YunchuWang Apr 6, 2024
42d7a3d
fix
YunchuWang Apr 6, 2024
21589e5
fix
YunchuWang Apr 6, 2024
69ed92d
revert
YunchuWang Apr 6, 2024
43114e7
fix
YunchuWang Apr 6, 2024
8923a44
fix
YunchuWang Apr 6, 2024
d90a2f8
fix
YunchuWang Apr 6, 2024
f44a28f
fix
YunchuWang Apr 6, 2024
b807e78
fix
YunchuWang Apr 6, 2024
ffc7a1f
fix
YunchuWang Apr 6, 2024
f53ddac
fix
YunchuWang Apr 6, 2024
d7d537b
fix
YunchuWang Apr 6, 2024
9682363
tests
YunchuWang Apr 6, 2024
a7505a0
fix
YunchuWang Apr 6, 2024
5f3565e
test
YunchuWang Apr 6, 2024
b702aaf
tests
YunchuWang Apr 6, 2024
98df5de
fix
YunchuWang Apr 6, 2024
462fad4
fix
YunchuWang Apr 6, 2024
c76c42c
fix
YunchuWang Apr 6, 2024
90a7db6
move init server
YunchuWang Apr 6, 2024
988f9ca
fix
YunchuWang Apr 7, 2024
67f679d
test
YunchuWang Apr 7, 2024
c41db16
update ppls
YunchuWang Apr 7, 2024
3f0bfb6
fix test
YunchuWang Apr 7, 2024
66f9edd
fix tests
YunchuWang Apr 7, 2024
ddc5f39
fix
YunchuWang Apr 7, 2024
5ce390a
fix
YunchuWang Apr 7, 2024
bc9ca7f
fix
YunchuWang Apr 7, 2024
680ed45
Revert "fix"
YunchuWang Apr 7, 2024
526765f
skip
YunchuWang Apr 7, 2024
4521741
fix tests
YunchuWang Apr 7, 2024
f5fff78
style
YunchuWang Apr 7, 2024
3e0075d
test
YunchuWang Apr 7, 2024
b96f74d
test
YunchuWang Apr 7, 2024
e68b41b
ff
YunchuWang Apr 7, 2024
a582688
test
YunchuWang Apr 7, 2024
d9bd32c
style
YunchuWang Apr 7, 2024
d664f65
skip
YunchuWang Apr 7, 2024
7bd566c
test
YunchuWang Apr 7, 2024
863f82b
fix
YunchuWang Apr 7, 2024
e220fc9
fix
YunchuWang Apr 7, 2024
0ea9207
fix
YunchuWang Apr 7, 2024
7e89528
replay
YunchuWang Apr 7, 2024
43b346c
f
YunchuWang Apr 7, 2024
6055378
fix
YunchuWang Apr 8, 2024
0a8f6df
codecov fix
YunchuWang Apr 8, 2024
265c821
Mount base extension to fix consumption test failures
YunchuWang Apr 8, 2024
68c2d90
style
YunchuWang Apr 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/ci_consumption_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
push:
branches: [ dev, main, release/* ]
pull_request:
branches: [ dev, main, release/* ]

jobs:
build:
Expand All @@ -30,10 +29,26 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get Date
id: get-date
run: |
echo "todayDate=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_ENV
shell: bash
- uses: actions/cache@v4
id: cache-pip
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ env.todayDate }}-${{ matrix.python-version }}
- name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U azure-functions --pre
python -m pip install -U -e .[dev]
if [[ "${{ matrix.python-version }}" != "3.7" ]]; then
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple --pre -U -e .[test-http-v2]
fi
- name: Install worker
run: |
python setup.py build
- name: Running 3.7 Tests
if: matrix.python-version == 3.7
Expand Down
27 changes: 21 additions & 6 deletions .github/workflows/ci_e2e_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ on:
push:
branches: [dev, main, release/*]
pull_request:
branches: [dev, main, release/*]
schedule:
# Monday to Thursday 3 AM CST build
# * is a special character in YAML so you have to quote this string
Expand All @@ -39,7 +38,27 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Install dependencies and the worker
- name: Get Date
id: get-date
run: |
echo "todayDate=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_ENV
shell: bash
- uses: actions/cache@v4
id: cache-pip
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ env.todayDate }}-${{ matrix.python-version }}
- name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U azure-functions --pre
python -m pip install -U -e .[dev]
# Conditionally install test dependencies for Python 3.8 and later
if [[ "${{ matrix.python-version }}" != "3.7" ]]; then
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple --pre -U -e .[test-http-v2]
fi
- name: Install worker
run: |
retry() {
local -r -i max_attempts="$1"; shift
Expand All @@ -58,10 +77,6 @@ jobs:
done
}

python -m pip install --upgrade pip
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U azure-functions --pre
python -m pip install -U -e .[dev]

# Retry a couple times to avoid certificate issue
retry 5 python setup.py build
retry 5 python setup.py webhost --branch-name=dev
Expand Down
42 changes: 33 additions & 9 deletions .github/workflows/ci_ut_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ on:
# * is a special character in YAML so you have to quote this string
- cron: "0 8 * * 1,2,3,4"
push:
pull_request:
branches: [ dev, main, release/* ]
pull_request:

jobs:
build:
Expand All @@ -37,7 +37,27 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Install dependencies and the worker
- name: Get Date
id: get-date
run: |
echo "todayDate=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_ENV
shell: bash
- uses: actions/cache@v4
id: cache-pip
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}-${{ env.todayDate }}-${{ matrix.python-version }}
- name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U azure-functions --pre
python -m pip install -U -e .[dev]
# Conditionally install test dependencies for Python 3.8 and later
if [[ "${{ matrix.python-version }}" != "3.7" ]]; then
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple --pre -U -e .[test-http-v2]
fi
- name: Install the worker
run: |
retry() {
local -r -i max_attempts="$1"; shift
Expand All @@ -55,11 +75,7 @@ jobs:
fi
done
}

python -m pip install --upgrade pip
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U azure-functions --pre
python -m pip install -U -e .[dev]


# Retry a couple times to avoid certificate issue
retry 5 python setup.py build
retry 5 python setup.py webhost --branch-name=dev
Expand All @@ -70,18 +86,26 @@ jobs:
AzureWebJobsStorage: ${{ secrets.LinuxStorageConnectionString310 }} # needed for installing azure-functions-durable while running setup.py
ARCHIVE_WEBHOST_LOGS: ${{ github.event.inputs.archive_webhost_logging }}
run: |
python -m pytest -q -n auto --dist loadfile --reruns 4 --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch tests/unittests
python -m pytest -q -n auto --replay-record-dir=build/tests/replay --dist loadfile --reruns 4 --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch tests/unittests
- name: Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml # optional
flags: unittests # optional
name: codecov # optional
fail_ci_if_error: false # optional (default = false)
token: ${{ secrets.CODECOV_TOKEN }}
- name: Publish Logs to Artifact
if: failure()
uses: actions/upload-artifact@v4
with:
name: Test WebHost Logs ${{ github.run_id }} ${{ matrix.python-version }}
path: logs/*.log
if-no-files-found: ignore
- name: Publish replays to Artifact
if: failure()
uses: actions/upload-artifact@v4
with:
name: Test Replays ${{ github.run_id }} ${{ matrix.python-version }}
path: build/tests/replay
if-no-files-found: ignore
7 changes: 5 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ name: Lint Code Base
#############################
# Start the job on all push #
#############################
on: [ push, pull_request, workflow_dispatch ]

on:
workflow_dispatch:
push:
branches: [ dev, main, release/* ]
pull_request:
###############
# Set the Job #
###############
Expand Down
45 changes: 44 additions & 1 deletion azure_functions_worker/bindings/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,53 @@
import sys
import typing

from .. import protos
from azure_functions_worker.constants import HTTP, HTTP_TRIGGER

from .. import protos
from . import datumdef
from . import generic
from .shared_memory_data_transfer import SharedMemoryManager
from ..constants import BASE_EXT_SUPPORTED_PY_MINOR_VERSION, \
PYTHON_ENABLE_INIT_INDEXING
from ..utils.common import is_envvar_true

PB_TYPE = 'rpc_data'
PB_TYPE_DATA = 'data'
PB_TYPE_RPC_SHARED_MEMORY = 'rpc_shared_memory'
BINDING_REGISTRY = None


def _check_http_input_type_annotation(bind_name: str, pytype: type) -> bool:
if sys.version_info.minor >= BASE_EXT_SUPPORTED_PY_MINOR_VERSION and \
is_envvar_true(PYTHON_ENABLE_INIT_INDEXING):
import azure.functions.extension.base as ext_base
if ext_base.HttpV2FeatureChecker.http_v2_enabled():
return ext_base.RequestTrackerMeta.check_type(pytype)

binding = get_binding(bind_name)
return binding.check_input_type_annotation(pytype)


def _check_http_output_type_annotation(bind_name: str, pytype: type) -> bool:
if sys.version_info.minor >= BASE_EXT_SUPPORTED_PY_MINOR_VERSION and \
is_envvar_true(PYTHON_ENABLE_INIT_INDEXING):
import azure.functions.extension.base as ext_base
if ext_base.HttpV2FeatureChecker.http_v2_enabled():
return ext_base.ResponseTrackerMeta.check_type(pytype)

binding = get_binding(bind_name)
return binding.check_output_type_annotation(pytype)


INPUT_TYPE_CHECK_OVERRIDE_MAP = {
HTTP_TRIGGER: _check_http_input_type_annotation
}

OUTPUT_TYPE_CHECK_OVERRIDE_MAP = {
HTTP: _check_http_output_type_annotation
}


def load_binding_registry() -> None:
func = sys.modules.get('azure.functions')

Expand Down Expand Up @@ -43,11 +78,19 @@ def is_trigger_binding(bind_name: str) -> bool:


def check_input_type_annotation(bind_name: str, pytype: type) -> bool:
global INPUT_TYPE_CHECK_OVERRIDE_MAP
if bind_name in INPUT_TYPE_CHECK_OVERRIDE_MAP:
return INPUT_TYPE_CHECK_OVERRIDE_MAP[bind_name](bind_name, pytype)

binding = get_binding(bind_name)
return binding.check_input_type_annotation(pytype)


def check_output_type_annotation(bind_name: str, pytype: type) -> bool:
global OUTPUT_TYPE_CHECK_OVERRIDE_MAP
if bind_name in OUTPUT_TYPE_CHECK_OVERRIDE_MAP:
return OUTPUT_TYPE_CHECK_OVERRIDE_MAP[bind_name](bind_name, pytype)

binding = get_binding(bind_name)
return binding.check_output_type_annotation(pytype)

Expand Down
19 changes: 18 additions & 1 deletion azure_functions_worker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
WORKER_STATUS = "WorkerStatus"
SHARED_MEMORY_DATA_TRANSFER = "SharedMemoryDataTransfer"
FUNCTION_DATA_CACHE = "FunctionDataCache"
HTTP_URI = "HttpUri"

# Platform Environment Variables
AZURE_WEBJOBS_SCRIPT_ROOT = "AzureWebJobsScriptRoot"
Expand Down Expand Up @@ -54,9 +55,25 @@
RETRY_POLICY = "retry_policy"

# Paths
CUSTOMER_PACKAGES_PATH = "/home/site/wwwroot/.python_packages/lib/site-packages"
CUSTOMER_PACKAGES_PATH = "/home/site/wwwroot/.python_packages/lib/site" \
"-packages"

# Flag to index functions in handle init request
PYTHON_ENABLE_INIT_INDEXING = "PYTHON_ENABLE_INIT_INDEXING"

METADATA_PROPERTIES_WORKER_INDEXED = "worker_indexed"

# HostNames
LOCAL_HOST = "127.0.0.1"

# Header names
X_MS_INVOCATION_ID = "x-ms-invocation-id"

# Trigger Names
HTTP_TRIGGER = "httpTrigger"

# Output Names
HTTP = "http"

# Base extension supported Python minor version
BASE_EXT_SUPPORTED_PY_MINOR_VERSION = 8
Loading
Loading