Patrick Tan

    Patrick Tan

    7 months ago
    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.
    Kevin Kho

    Kevin Kho

    7 months ago
    Hey @Patrick Tan, you can call a task with task.run()so
    @task
    def abc():
        return 1
    
    abc.run()
    or you can convert a function to a task during runtime
    def abc():
        return 1
    
    abc_task = task(abc)
    Anna Geller

    Anna Geller

    7 months ago
    Do you know that you can run Prefect flows locally just like normal Python scripts?
    Patrick Tan

    Patrick Tan

    7 months ago
    Thanks @Kevin Kho, works like a charm!