Skip to content

New programming model lib change#99

Merged
YunchuWang merged 36 commits intodevfrom
wangbill/new-decorators
Mar 7, 2022
Merged

New programming model lib change#99
YunchuWang merged 36 commits intodevfrom
wangbill/new-decorators

Conversation

@YunchuWang
Copy link
Copy Markdown
Member

@YunchuWang YunchuWang commented Feb 1, 2022

New programming model library change

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 1, 2022

✅ Result of Pytest Coverage

---------- coverage: platform linux, python 3.6.15-final-0 -----------

Name Stmts Miss Cover
azure/init.py 1 0 0
azure/functions/init.py 26 0 0
azure/functions/_abc.py 268 66 32
azure/functions/_cosmosdb.py 20 2 6
azure/functions/_durable_functions.py 41 12 18
azure/functions/_eventgrid.py 57 2 4
azure/functions/_eventhub.py 38 1 8
azure/functions/_http.py 104 11 30
azure/functions/_http_asgi.py 70 1 22
azure/functions/_http_wsgi.py 98 5 32
azure/functions/_kafka.py 26 6 2
azure/functions/_queue.py 39 5 8
azure/functions/_servicebus.py 91 22 2
azure/functions/_utils.py 25 3 10
azure/functions/blob.py 73 0 18
azure/functions/cosmosdb.py 39 10 20
azure/functions/decorators/init.py 4 0 0
azure/functions/decorators/_http.py 26 0 6
azure/functions/decorators/constants.py 11 0 0
azure/functions/decorators/core.py 59 3 22
azure/functions/decorators/cosmosdb.py 53 0 6
azure/functions/decorators/eventhub.py 21 0 4
azure/functions/decorators/function_app.py 218 2 34
azure/functions/decorators/queue.py 19 0 4
azure/functions/decorators/servicebus.py 43 0 8
azure/functions/decorators/timer.py 12 0 2
azure/functions/decorators/utils.py 71 1 36
azure/functions/durable_functions.py 60 10 8
azure/functions/eventgrid.py 44 2 16
azure/functions/eventhub.py 130 28 60
azure/functions/extension/init.py 5 0 0
azure/functions/extension/app_extension_base.py 20 4 2
azure/functions/extension/app_extension_hooks.py 6 0 2
azure/functions/extension/extension_hook_meta.py 4 0 2
azure/functions/extension/extension_meta.py 74 0 24
azure/functions/extension/extension_scope.py 5 0 2
azure/functions/extension/func_extension_base.py 26 4 6
azure/functions/extension/func_extension_hooks.py 6 0 2
azure/functions/extension/function_extension_exception.py 2 0 2
azure/functions/http.py 66 43 28
azure/functions/kafka.py 134 20 50
azure/functions/meta.py 180 25 104
azure/functions/queue.py 59 31 18
azure/functions/servicebus.py 192 22 50
azure/functions/timer.py 18 6 4
TOTAL 2584 347 714
======================== 259 passed, 1

Comment thread azure/functions/__init__.py Outdated
Comment thread azure/functions/decorators/__init__.py Outdated
Comment thread azure/functions/__init__.py Outdated
Comment thread azure/functions/__init__.py Outdated
Comment thread azure/functions/decorators/blob.py Outdated
Comment thread azure/functions/decorators/core.py Outdated
Comment thread azure/functions/decorators/cosmosdb.py Outdated
Comment thread azure/functions/decorators/function_app.py Outdated
Comment thread azure/functions/decorators/function_app.py
Comment thread azure/functions/decorators/function_app.py
Comment thread azure/functions/decorators/eventhub.py Outdated
Comment thread azure/functions/decorators/http.py Outdated
Comment thread azure/functions/decorators/http.py Outdated
Comment thread azure/functions/decorators/http.py Outdated
Comment thread azure/functions/decorators/http.py Outdated
Comment thread tests/decorators/test_core.py Outdated
Comment thread tests/decorators/test_core.py Outdated
Comment thread tests/decorators/test_core.py
Comment thread tests/decorators/test_core.py
Comment thread tests/decorators/test_cosmosdb.py
Comment thread azure/functions/__init__.py Outdated
Comment thread azure/functions/decorators/core.py Outdated
Comment thread azure/functions/decorators/function_app.py Outdated
Comment thread azure/functions/decorators/core.py
Comment thread azure/functions/decorators/eventhub.py Outdated
Comment thread azure/functions/decorators/http.py Outdated
Comment thread azure/functions/decorators/http.py Outdated
Comment thread azure/functions/decorators/http.py Outdated
Comment thread azure/functions/decorators/http.py Outdated
Comment thread azure/functions/decorators/queue.py Outdated
Copy link
Copy Markdown
Member

@vrdmr vrdmr left a comment

Choose a reason for hiding this comment

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

Round 2 comments. Will complete the review by tonight.

from ._cosmosdb import Document, DocumentList
from ._http import HttpRequest
from ._http import HttpResponse
from .decorators import (FunctionApp, Function, DataType, AuthLevel,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please keep the imports in the way they were already - The ._* imports separate from .* imports - for now. We should consolidate and the imports better soon - and explore isort in future during tests - or recommit hooks (or integrating it with PyCharm).

Comment thread azure/functions/decorators/__init__.py Outdated
Comment thread azure/functions/decorators/constants.py Outdated
Comment thread azure/functions/decorators/core.py Outdated
Comment thread azure/functions/decorators/core.py Outdated
Comment thread azure/functions/decorators/core.py Outdated
Comment thread azure/functions/decorators/core.py
Comment thread azure/functions/decorators/eventhub.py Outdated
Comment thread azure/functions/decorators/http.py Outdated
Comment thread azure/functions/decorators/queue.py
Comment thread azure/functions/decorators/core.py
Comment thread azure/functions/decorators/core.py Outdated
Comment thread azure/functions/decorators/constants.py Outdated
Comment thread azure/functions/decorators/core.py
Copy link
Copy Markdown
Member

@vrdmr vrdmr left a comment

Choose a reason for hiding this comment

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

Comments v3. Getting there.

Comment thread azure/functions/decorators/core.py Outdated
Comment thread azure/functions/decorators/queue.py Outdated
Comment thread azure/functions/decorators/utils.py Outdated
Comment thread azure/functions/decorators/utils.py Outdated
return words[0] + ''.join(ele.title() for ele in words[1:])


class CustomJsonEncoder(JSONEncoder):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a one-line comment - of why you needed a CustomJSONEncoder. Also, the update class name to CustomJSONEncoder to denote the subclass of the JSONEncoder.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you think of a better name than Custom - something which signifies what is custom about this JSONEncoder?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just a one-line comment - of why you needed a CustomJSONEncoder. Also, the update class name to CustomJSONEncoder to denote the subclass of the JSONEncoder.

Making enum str or int as first subclass i tried will make it a str or int type instead of enum, and
def parse_singular_param_to_enum(param: Optional[Union[T, str]], class_name: Type[T]) -> Optional[T]: would fail as no way to tell whether its a "GET" or HttpMethod.GET, they have same type str.

Comment thread azure/functions/decorators/utils.py Outdated


class TestCosmosDB(unittest.TestCase):
def test_cosmos_db_trigger_valid_creation(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also add a test scenario where you are sending only the minimal stuff - we want to check the function.json when Nones are automatically set

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment applies to all the triggers and bindings.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need not be part of this PR though

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay - I got my partial answer - you are validating function.json with fewer args.

Comment thread tests/decorators/test_decorators.py Outdated
self.assertTrue(isinstance(func.get_trigger(), HttpTrigger))
self.assertTrue(func.get_trigger().route, "dummy")

def test_timer_trigger_default_args(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Something to think about - as this test file is becoming bigger - have you explored some thoughts to breakup the tests into its own classes

A top-level class TestDecorators can have the basic stuff that individual test classes can inherit (eg the self.func_app = FunctionApp() as common setup)

and then class TestHTTPDecorators(TestDecorators), class TestTimerDecorators(TestDecorators), etc. can come in to make the handling of this long file easier. And also helps in test management on our end.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not for this PR though. CodeCoverage is more important currently.

Comment thread tests/decorators/test_decorators.py Outdated
Comment thread tests/decorators/test_decorators.py Outdated
Comment thread tests/decorators/test_decorators.py Outdated
Copy link
Copy Markdown
Member

@vrdmr vrdmr left a comment

Choose a reason for hiding this comment

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

🚢

@YunchuWang YunchuWang merged commit dc2b691 into dev Mar 7, 2022
@YunchuWang YunchuWang deleted the wangbill/new-decorators branch March 7, 2022 18:45
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

Successfully merging this pull request may close these issues.

4 participants