s

    Stefan

    1 week ago
    Looking for solutions on how to "call a task from within a task" • My main task, "Get data from sql" will get the data. • Within the above function, I run another function to generate the SQL-statement with the specifics sent into the parent function (such as a date from a list of datetimes). • Since I cannot decorate the sql-generating function with a @Task - how can I run it and still see it in Prefect? I see from the docs that my options are either 1) use sql.fn() or 2) not decorate it with a @Task - neither of which will not generate a task run. Here is a mockup: @task
    def sql_builder(date):
    statement = statement generator with date and tables
    return statement
    @task
    def get_data(date):
    sql = sql_builder(date)
    get_data(sql, con)
    t

    Tony Piazza

    1 week ago
    @Stefan why not make the get_data function a flow instead? your flow can call it directly as a subflow.
    s

    Stefan

    1 week ago
    Thank for your reply. My first thought was that would seem pretty overkill to generate that amount of Flow-runs in addition to the main one, especially if I'm doing a year's worth of data (one subflow per day) (imagine the UI)
    t

    Tony Piazza

    1 week ago
    curious why do you need to "see it in Prefect" ?
    s

    Stefan

    1 week ago
    To take advantage of what Prefect has to offer for tasks? See output, use retries, map-function, tags.
    t

    Tony Piazza

    1 week ago
    then it has to be either a task or flow. will be interested to see how you decide to implement it.
    Bianca Hoch

    Bianca Hoch

    1 week ago
    Hi Stefan, we wouldn't recommend using
    .fn()
    due to the fact that you lose all orchestration functionality that prefect tasks have. You can, however, have a flow call the task, and a flow call a flow.
    s

    Stefan

    1 week ago
    Thanks @Bianca Hoch!