Skip to content

Http V2 Extensions #1

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

Merged
merged 28 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
61 changes: 61 additions & 0 deletions .github/workflows/ci_ut_ext_base_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: UT CI Run for Python Extension Base

on:
push:
branches: [ dev, master, main, release/* ]
paths:
- 'azure-functions-extension-base/**'
pull_request:
branches: [ dev, master, main, release/* ]
paths:
- 'azure-functions-extension-base/**'

jobs:
build:
name: "Python Extension Base UT CI Run"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
permissions: read-all
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
working-directory: azure-functions-extension-base
run: |
python -m pip install --upgrade pip
python -m pip install -U -e .[dev]

- name: Run Unit Tests
working-directory: azure-functions-extension-base
env:
AzureWebJobsStorage: ${{ secrets.AzureWebJobsStorage }}
run: |
python -m pytest -q --instafail --cov=. --cov-report xml --cov-branch tests

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./azure-functions-extension-base/coverage.xml
flags: unittests
name: codecov
fail_ci_if_error: false

- name: Notify dedicated teams channel
uses: jdcargile/[email protected]
if: failure()
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: "Python Extension Base UT CI Failed for Python ${{ matrix.python-version }}"
notification-color: 17a2b8
timezone: America/Denver
verbose-logging: false
64 changes: 64 additions & 0 deletions .github/workflows/ci_ut_ext_blob_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: UT CI Run for Python Extension Blob

on:
push:
branches: [ dev, master, main, release/* ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as the base extension workflow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

paths:
- 'azure-functions-extension-base/**'
- 'azure-functions-extension-blob/**'
pull_request:
branches: [ dev, master, main, release/* ]
paths:
- 'azure-functions-extension-base/**'
- 'azure-functions-extension-blob/**'

jobs:
build:
name: "Python Extension Blob UT CI Run"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ 3.9, "3.10", "3.11" ]
permissions: read-all
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
working-directory: azure-functions-extension-blob
run: |
python -m pip install --upgrade pip
python -m pip install -U -e .[dev]
python -m pip install -e ../azure-functions-extension-base
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test this with the published base. If there are base changes then we should publish the base then the extensions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove


- name: Run Unit Tests
working-directory: azure-functions-extension-blob
env:
AzureWebJobsStorage: ${{ secrets.AzureWebJobsStorage }}
run: |
python -m pytest -q --instafail --cov=. --cov-report xml --cov-branch tests

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./azure-functions-extension-blob/coverage.xml
flags: unittests
name: codecov
fail_ci_if_error: false

- name: Notify dedicated teams channel
uses: jdcargile/[email protected]
if: failure()
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: "Python Extension Blob UT CI Failed for Python ${{ matrix.python-version }}"
notification-color: 17a2b8
timezone: America/Denver
verbose-logging: false
62 changes: 62 additions & 0 deletions .github/workflows/ci_ut_ext_fastapi_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: UT CI Run for Python Extension FastApi

on:
push:
branches: [ dev, master, main, release/* ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

paths:
- 'azure-functions-extension-fastapi/**'
pull_request:
branches: [ dev, master, main, release/* ]
paths:
- 'azure-functions-extension-fastapi/**'

jobs:
build:
name: "Python Extension UT FastApi CI Run"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
permissions: read-all
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
working-directory: azure-functions-extension-fastapi
run: |
python -m pip install --upgrade pip
python -m pip install -U -e .[dev]
python -m pip install -e ../azure-functions-extension-base

- name: Run Unit Tests
working-directory: azure-functions-extension-fastapi
env:
AzureWebJobsStorage: ${{ secrets.AzureWebJobsStorage }}
run: |
python -m pytest -q --instafail --cov=. --cov-report xml --cov-branch tests

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./azure-functions-extension-fastapi/coverage.xml
flags: unittests
name: codecov
fail_ci_if_error: false

- name: Notify dedicated teams channel
uses: jdcargile/[email protected]
if: failure()
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: "Python Extension FastApi UT CI Failed for Python ${{ matrix.python-version }}"
notification-color: 17a2b8
timezone: America/Denver
verbose-logging: false
13 changes: 12 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ 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:
branches:
- dev
- main
- 'release/*'

###############
# Set the Job #
Expand Down
39 changes: 2 additions & 37 deletions azure-functions-extension-base/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
# Azure Functions Extension Base library for Python
This is the base library for allowing Python Function Apps to recognize and bind to SDk-types. It is not to be used directly.
Instead, please reference one of the extending packages.

Currently, the supported SDK-type bindings are:

* Azure Storage Blob

## Next steps

### More sample code

Get started with our [Blob samples](hhttps://github.com/Azure/azure-functions-python-extensions/tree/main/azure-functions-extension-blob/samples).

Several samples are available in this GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Storage Blobs:

* [blob_samples_blobclient](https://github.com/Azure/azure-functions-python-extensions/tree/main/azure-functions-extension-blob/samples/blob_samples_blobclient) - Examples for using the BlobClient type:
* From BlobTrigger
* From BlobInput

* [blob_samples_containerclient](https://github.com/Azure/azure-functions-python-extensions/tree/main/azure-functions-extension-blob/samples/blob_samples_containerclient) - Examples for using the ContainerClient type:
* From BlobTrigger
* From BlobInput

* [blob_samples_storagestreamdownloader](https://github.com/Azure/azure-functions-python-extensions/tree/main/azure-functions-extension-blob/samples/blob_samples_storagestreamdownloader) - Examples for using the StorageStreamDownloader type:
* From BlobTrigger
* From BlobInput

### Additional documentation
For more information on the Azure Storage Blob SDK, see the [Azure Blob storage documentation](https://docs.microsoft.com/azure/storage/blobs/) on docs.microsoft.com
and the [Azure Storage Blobs README](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage-blob).

## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
This is the base library for allowing Python Function Apps to recognize and bind to SDk-types and HttpV2-types. It is not to be used directly.
Instead, please reference one of the extending packages.
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from .meta import (Datum, _ConverterMeta, _BaseConverter,
InConverter, OutConverter, get_binding_registry)
from .meta import (
Datum,
_ConverterMeta,
_BaseConverter,
InConverter,
OutConverter,
get_binding_registry
)
from .sdkType import SdkType
from .web import (
WebServer,
WebApp,
ModuleTrackerMeta,
RequestTrackerMeta,
ResponseTrackerMeta,
http_v2_enabled,
ResponseLabels
)

__all__ = ['Datum', '_ConverterMeta', '_BaseConverter',
'InConverter', 'OutConverter',
'SdkType', 'get_binding_registry']
__all__ = [
'Datum',
'_ConverterMeta',
'_BaseConverter',
'InConverter',
'OutConverter',
'SdkType',
'get_binding_registry',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is get_binding_registry exposed? same with http_v2_enabled

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_binding_registry is used in the worker. It returns the binding registry

'ModuleTrackerMeta',
'RequestTrackerMeta',
'ResponseTrackerMeta',
'http_v2_enabled',
'ResponseLabels',
'WebServer',
'WebApp'
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Licensed under the MIT License.

from abc import abstractmethod
from typing import Any, Optional

import sys
from typing import Any, Dict, Optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did flake8 succeed here? Any and Optional are not used


class SdkType:
def __init__(self, *, data: Optional[dict[str, Any]] = None):
def __init__(self, *, data: dict = None):
self._data = data or {}

@abstractmethod
Expand Down
Loading