Hi everyone, I was wondering if there is a way to ...
# ask-community
a
Hi everyone, I was wondering if there is a way to manipulate tasks and flows on the fly generically, e.g. like a wrapper to start tasks and flows. What I intend to do is to have a wrapper for tasks and flows, so we can build pipelines similar to sklearn Api. Here, I wrote a simple function to wrap a task, you can extend the idea to many tasks, but I'd like to hear your opinions, if there is a better way to implement this. Thanks in advance.
n
i dont think you need an extra class or wrapper for cases like this, just
with_options
Copy code
from prefect import task

@task
def barebones(x): print(x)

barebones.with_options(log_prints=True, task_run_name="running {x}")(42)
gives
Copy code
13:51:28.690 | INFO    | Task run 'running 42' - 42
13:51:28.696 | INFO    | Task run 'running 42' - Finished in state Completed()
same goes for flows
a
Thanks for the reply and code snippet.