Summary
The user wants to create a custom task that enhances their existing tasks by collecting metrics, sending events to another API, and invoking the logic of wrapped tasks. They are asking if Flyte has a built-in feature for this or if they should create a decorator to wrap Flyte's task decorator. The response suggests using wrappers to achieve this, providing an example of how to wrap a flytekit.task
object for more granular control. Additionally, a link shared by another user is mentioned as a simpler and effective solution for most use cases.
yanive
<@U062Y21KSQG>
kumare
the link is essentially a secondary decorator
mhagel
To the best of my knowledge, the best option is to use wrappers. These can wrap an eventually returned flytekit.task
object if you want to be more granular and wrap the underlying task function itself, such as:
@functools.wraps(func)
def special_logger(*args): ...
function_task = flytekit.task(
_task_function=special_logger,
...
)
return function_task```
The link provided by <@UNZB4NW3S> provides a probably simpler and effective solution for most use cases.
kumare
you can write wrapper decorators - as explained https://docs.flyte.org/en/latest/user_guide/advanced_composition/decorating_tasks.html#id1|here
yanive
Hi everyone! I would like to create a custom task that extends the logic of my other existing tasks. My custom task should collect some metrics, send events to another API, and invoke the logic of the tasks it wraps. Does Flyte have an out-of-the-box feature for this, or should I create a decorator that wraps Flyte's task decorator? Thank you!