F

Flyte enables you to build & deploy data & ML pipelines, hassle-free. The infinitely scalable and flexible workflow orchestration platform that seamlessly unifies data, ML and analytics stacks. Explore and Join the Flyte Community!

Custom Task Creation in Flyte

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.

Status
resolved
Tags
  • flyte
  • Task Customization
  • Task Enhancement
  • Another API
  • Developer
  • flytekit.task
  • Question
  • Developer Help
  • API
Source
#ask-the-community
    y

    yanive

    11/5/2024

    <@U062Y21KSQG>

    k

    kumare

    11/5/2024

    the link is essentially a secondary decorator

    m

    mhagel

    11/5/2024

    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.
    
    k

    kumare

    11/5/2024
    y

    yanive

    11/4/2024

    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!