https://prefect.io logo
Title
c

Christian Nuss

07/18/2022, 8:57 PM
question: is doing
.run(...)
on a task within a task an antipattern?
example:
@task
def do_other_stuff(name: str)
  return f"hello {name}"

@task
def do_stuff():
  result = do_other_stuff.run("christian")
k

Kevin Kho

07/18/2022, 9:03 PM
It’s not. Just know it’s not a first class task with retries and results and state tracking. It’s just the python under the hood.
c

Christian Nuss

07/18/2022, 9:16 PM
gotcha!
so related: is this a way to create a general "helper" function to "say_hello"?
@task
def generate_name():
  return "christian"

@task
def generate_hello(name: str):
  return f"hello {name}"

def say_hello():
  name = generate_name()
  hello = generate_hello(name)
  return hello

with Flow(...):
  response = say_hello()
k

Kevin Kho

07/18/2022, 9:23 PM
Yeah that is fine. Not sure if you need the return but that will work!