Has anyone tried extending the flow and task decor...
# ask-community
a
Has anyone tried extending the flow and task decorators to add some common functionality across flows?
d
Hi Can you be more specific ?
a
Things like common logging or task runners, or artifact creation
d
Just new decorator that implements storage and cache parameters based on the environment .
cached_task
and
stored_task
a
The problem is that flow and task decorators return the Flow and Task objects
d
overwritten with with_options
a
Not following, I’m relatively new with python. Can you share an example?
d
Copy code
def stored_task(**k_args):
    """Decorator for standardized storage enabled tasks"""

    def decorator(fn):
        """Passes function"""

        @task
        def _inner(*inner_args, **inner_k_args):
            """Task decoration method"""
            return fn(*inner_args, **inner_k_args)

        return _inner.with_options(**k_args, **get_storage_parameters())

    return decorator
ah if you are new to python, this might confuse you more.
what is your issue?
a
That implementation returns a function where the @task decorator returns a Task object