Skip to content

Derive method task inputs and outputs from the function signature - #505

Draft
woutdenolf wants to merge 1 commit into
mainfrom
function_task_inputs_outputs
Draft

woutdenolf wants to merge 1 commit into
mainfrom
function_task_inputs_outputs

Conversation

@woutdenolf

@woutdenolf woutdenolf commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

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_inputs and output_names.

AI Disclosure

  • No AI used
  • AI tool Clause used for generate prototype

@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.16129% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/ewokscore/methodtask.py 95.72% 5 Missing ⚠️
src/ewokscore/inittask.py 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@woutdenolf
woutdenolf force-pushed the function_task_inputs_outputs branch 4 times, most recently from dba5eb6 to d61c643 Compare September 8, 2026 19:35
@woutdenolf woutdenolf added this to the v6.0.0 milestone Sep 8, 2026
@woutdenolf
woutdenolf force-pushed the function_task_inputs_outputs branch 4 times, most recently from 41777ea to eea6a60 Compare September 9, 2026 05:24
@woutdenolf
woutdenolf force-pushed the function_task_inputs_outputs branch from eea6a60 to ef496df Compare September 9, 2026 05:33
if issubclass(return_type, dict):
# A TypedDict is a dict subclass with annotated keys
return tuple(_type_hints(return_type))
return tuple()

@woutdenolf woutdenolf Sep 9, 2026 •

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.

@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:

  1. 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.
  2. Introduce a decorator to opt-in or opt-out unpacking. The task author decides.
  3. 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.

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.

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?

@woutdenolf woutdenolf Sep 10, 2026 •

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.

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.

This branch has not been deployed

No deployments
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.

2 participants