https://prefect.io logo
p

Patrick Tan

02/18/2022, 4:37 PM
Hello, I am new to Prefect. I want to structure my code so it can be run as Prefect workflow and optionally normal python program (Not as Prefect workflow). All functions has Task decorator and it can't be called like normal Python function. Please advise.
k

Kevin Kho

02/18/2022, 4:39 PM
Hey @Patrick Tan, you can call a task with `task.run()`so
Copy code
@task
def abc():
    return 1

abc.run()
or you can convert a function to a task during runtime
Copy code
def abc():
    return 1

abc_task = task(abc)
upvote 2
👍 1
a

Anna Geller

02/18/2022, 4:39 PM
Do you know that you can run Prefect flows locally just like normal Python scripts?
p

Patrick Tan

02/18/2022, 8:04 PM
Thanks @Kevin Kho, works like a charm!
👍 1