Repository navigation
Derive method task inputs and outputs from the function signature - #505
woutdenolf wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
dba5eb6 to
d61c643
Compare
41777ea to
eea6a60
Compare
eea6a60 to
ef496df
Compare
| if issubclass(return_type, dict): | ||
| # A TypedDict is a dict subclass with annotated keys | ||
| return tuple(_type_hints(return_type)) | ||
| return tuple() |
There was a problem hiding this comment.
@loichuder In the current proto-type when the return type annotation is of a certain kind (pydantic model, named tuple, dataclass, TypeDict), we unpack the outputs, there is no opt-out.
Choices we have:
- Add a new
task_type. Costly since several places need to learn about the new type (ewokscore, all engine bindings, ewoksweb, ewoksjob). Workflow author decides. - Introduce a decorator to opt-in or opt-out unpacking. The task author decides.
- Only unpack BaseOutputModel.
The first would be inline with method vs. ppfmethod for example. Any method could be either and the workflow author decides. But it is more costly though. Perhaps the way we implement task types needs to be revisited.
There was a problem hiding this comment.
Perhaps I jumped the gun and there will be no situation where someone wants to opt-out from this since it seems way more practical.
Should we more forward with unconditional unpacking and revisit if someone complains?
There was a problem hiding this comment.
I think it is was a fair remark and just like ppfmethod changes the way we are using python functions we should do the same (imo) for unpackedmethod (or whatever we call it).
Since it is another task_type (doesn't happen every day but it will again) I think this is also a simple use case to validate the approach proposed in #508.
In any case, all this came from a taste PR, not a real need so not urgent. Next major release.
PR summary
Generate a task class with inputs/outputs for
task_type = "method"based on the function signature.Pydantic models generated when possible. Fall-back to the non-typed
input_names,optional_input_names,n_required_positional_inputsandoutput_names.AI Disclosure