-
Notifications
You must be signed in to change notification settings - Fork 107
[Do not merge] Add a test for custom bindings #379
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
Conversation
cc: @maiqbal11 @asavaritayal @anirudhgarg @elprans - Can you please take a look? Should the dataType be set in function.json? |
@pragnagopa Yes, for custom bindings the dataType should be set in function.json |
@elprans Thanks. Do you have an example? |
azure-functions-python-worker/tests/blob_functions/get_blob_as_bytes/function.json Lines 1 to 24 in b31ede8
|
I tested this out and it doesn't work for Is it possible for it to work like the JavaScript worker when the dataType is not specified and allow binding to a {
"type": "signalRConnectionInfo",
"direction": "in",
"name": "connectionInfo",
"hubName": "chat"
} def main(req: func.HttpRequest, connectionInfo: dict) -> func.HttpResponse:
return func.HttpResponse(json.dumps(connectionInfo), mimetype='application/json') |
Can you elaborate here? On the protocol level everything is either a string or an array of bytes. It seems what you are looking for is the ability to say |
I believe an undefined If
|
Undefined |
That makes sense. But even without |
Matching the JavaScript implementation is not a goal. The Python implementation provides "rich" bindings by default, so the behavior is closer to C# rather than JavaScript. Doing an implicit |
@elprans - if @anthonychu - let me know if providing singnalRInfo as json would unblock your scenario. |
cc @jeffhollan for more context |
@pragnagopa Why can't we add an explicit "json" setting? Implicit decoding attempt seems very fragile to me. Changing the type of the value based on the input (as opposed to an explicit declaration) isn't a good thing. Unless we declare and document otherwise, the worker cannot rely on the type annotations. Otherwise we create a weird situation where it's not clear whether function.json is authoritative or the function declaration is. |
@anthonychu I imagine your goal here is to make sure the bindings behave even if the user doesn't explicitly set a @elprans is the alternative here so that a blank / default |
I think it would be okay to set a If |
I think right approach is to use type annotations if the function expects a custom type such as
Python worker needs to convert the input data sent by the functions host to the type requested by the function. This is the goal of issue #135 as well. Here is the flow for the above example:
@elprans - Any suggestions on how above flow can be achieved? |
Resolved with #409 |
Does the new support for raw data types allow bindings that are not known to the worker? I wasn't able to get the SignalRConnectionInfo binding working. Here's a test to show what I'm trying to do. Thanks.