Skip to content

Feature: consider adding generic support for dataclass-based bindings #416

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

Open
elprans opened this issue May 10, 2019 · 3 comments
Open
Assignees
Labels
Milestone

Comments

@elprans
Copy link
Collaborator

elprans commented May 10, 2019

Following up on the conversations in #66, and #409.

One possible way to implement generic handling of bindings is to allow users to annotate function parameters with a dataclass. The argument data is then treated as a conforming JSON object.

For example:

import dataclasses

@dataclasses.dataclass
class MyType:
    id: int
    body: str

def func(arg: MyType) -> str:
    return arg.body

In function.json such bindings would then have to specify dataType: json.

\cc @asavaritayal @pragnagopa @maiqbal11

@pragnagopa
Copy link
Member

given the annotation arg: MyType, can you please explain why dataType: json is needed?

@elprans
Copy link
Collaborator Author

elprans commented May 10, 2019

@pragnagopa How does host decide which format to use when sending data to the worker?

@pragnagopa
Copy link
Member

default behavior is to check if a string is a json valid. For example, queue trigger like {"id":99, "name":"test"} should be sent with TypedData set to json: https://github.com/Azure/azure-functions-language-worker-protobuf/blob/dev/src/proto/FunctionRpc.proto#L284

@asavaritayal asavaritayal added this to the Backlog milestone May 13, 2019
@stefanushinardi stefanushinardi added on-hold Needs further discussion. and removed func-stack: Python needs-discussion labels Dec 14, 2021
@stefanushinardi stefanushinardi self-assigned this Dec 14, 2021
@stefanushinardi stefanushinardi added the P2 [P2] items : Not ship blocking label Dec 14, 2021
@hallvictoria hallvictoria added feature and removed on-hold Needs further discussion. P2 [P2] items : Not ship blocking labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants