Add helpers to create task inputs and execute/submit one task#63
Add helpers to create task inputs and execute/submit one task#63poautran wants to merge 1 commit into
Conversation
|
In GitLab by @tvincent on Dec 19, 2024, 16:20 GMT+1: requested review from @woutdenolf |
|
In GitLab by @tvincent on Dec 19, 2024, 16:24 GMT+1: mentioned in merge request ewokscore!263 |
|
Discussion in GitLab: In GitLab by @tvincent on Dec 19, 2024, 16:26 GMT+1: CI fails for an unrelated issue: In GitLab by @woutdenolf on Dec 20, 2024, 11:43 GMT+1: https://gitlab.esrf.fr/workflow/ewoks/ewoks/-/merge_requests/188 |
|
In GitLab by @woutdenolf on Dec 20, 2024, 17:12 GMT+1: approved this merge request |
|
In GitLab by @woutdenolf on Dec 21, 2024, 15:39 GMT+1: unapproved this merge request |
| inputs: Optional[Union[Mapping, List[Mapping]]] = None, | ||
| task_type: str = "class", | ||
| **options, | ||
| ): |
There was a problem hiding this comment.
In GitLab by @woutdenolf on Dec 21, 2024, 15:42 GMT+1:
Suppose we want to run this function with ewoks
# mytasks.py
def sumfunc(a, b):
return a+bIf the idea is to provide an API that is as close to calling a normal python function, how about this?
sumab = execute_task("mytasks.sumfunc", task_type="method")(a=10, b=20)And if the default task_type is "method"
sumab = execute_task("mytasks.sumfunc")(a=10, b=20)And since we can handle positional arguments as well
sumab = execute_task("mytasks.sumfunc")(10, 20)which is as close as it gets to
sumab = sumfunc(10, 20)essentially
sumfunc = execute_task("mytasks.sumfunc")There was a problem hiding this comment.
In GitLab by @woutdenolf on Dec 21, 2024, 15:49 GMT+1:
Same goes for submit_task.
There was a problem hiding this comment.
In GitLab by @tvincent on Jan 6, 2025, 10:31 GMT+1:
Makes sense!
As it is, I made it similar to execute_graph and submit_graph API but it would be more pythonic this way like the first attempt for this (https://gitlab.esrf.fr/workflow/ewoks/ewokscore/-/merge_requests/263).
There was a problem hiding this comment.
In GitLab by @tvincent on Jan 6, 2025, 14:21 GMT+1:
And if the default
task_typeis"method"
I used "class" type by default since for execute_task at least it is of limited interest to call method task.
Best IMO would be to see if a "auto" task_type is possible: It sound possible for class, method, graph, script and notebook types at least.
There was a problem hiding this comment.
In GitLab by @tvincent on Jan 6, 2025, 14:26 GMT+1:
Using positional only args can also be considered:
def execute_task(task, task_type: str = "class", options: Optional[dict] = None, /, **kwargs):
...
sumab = execute_task("mytasks.sumfunc", "method", a=10, b=20)
sumab = execute_task("mytasks.sumtask", a=10, b=20)though it's a bit cumbersome to pass extra options (here the task_type MUST also be provided)
| if task_identifier is not None: | ||
| task_selector["task_identifier"] = task_identifier | ||
|
|
||
| return [{**task_selector, "name": k, "value": v} for k, v in inputs.items()] |
There was a problem hiding this comment.
In GitLab by @woutdenolf on Dec 21, 2024, 15:49 GMT+1:
Since task_inputs is public, in which situation would you use it?
Note that ewoks is not installed in the bliss side. If you need it in blissoda then ewoksutils is the best option (dependency of ewoksjob[client] which is installed on the bliss side).
There was a problem hiding this comment.
In GitLab by @tvincent on Jan 6, 2025, 10:31 GMT+1:
That would be useful in blissoda and scripts/GUI like in https://gitlab.esrf.fr/workflow/workflowhub/id31workflows.
I'll make a PR with it on ewoksutils.
There was a problem hiding this comment.
In GitLab by @tvincent on Jan 6, 2025, 13:54 GMT+1:
PR in ewoksutils: https://gitlab.esrf.fr/workflow/ewoks/ewoksutils/-/merge_requests/32
|
In GitLab by @tvincent on Jan 6, 2025, 13:54 GMT+1: mentioned in merge request ewoksutils!32 |
9332091 to
cfde0c6
Compare
In GitLab by @tvincent on Dec 19, 2024, 16:20 GMT+1:
This PR proposes to add a few helpers to run workflow with a single task and to write list of task inputs.
I didn't put tests for submit_task since it would need a worker.
Assignees: tvincent
Reviewers: @woutdenolf
Migrated from GitLab: https://gitlab.esrf.fr/workflow/ewoks/ewoks/-/merge_requests/189