Thread
#prefect-community
    Madison Schott

    Madison Schott

    1 year ago
    What would be the correct syntax to naming my tasks? The
    name=""
    suggested in the documentation isn't working for the format I have my tasks in
    campaign_details_dbt_run = dbt_task(name="Campaign Details", command='dbt run -m campaign_details')
    and
    dbt_task = DbtShellTask())
    Kevin Kho

    Kevin Kho

    1 year ago
    The name should go in the init so
    dbt_task = DbtShellTask(name="...")
    Madison Schott

    Madison Schott

    1 year ago
    there's no way to name the other tasks? Because I use the same DbtShellTask() for different commands that I want to name
    Kevin Kho

    Kevin Kho

    1 year ago
    You can template the
    task run name
    based on inputs like this ? But for the actual task name, I don’t think so. You could have DbtShellTask in your flow code like this:
    with Flow(...) as flow:
        a = DbtShellTask(name=...)(cmd=...)
        b = DbtShellTask(name=...)(cmd=...)
    Madison Schott

    Madison Schott

    1 year ago
    hmm but I don't want to have to keep reusing DbtShellTask since it has a my kwargs and some other info that would be repetitive
    I just need it so each of these tasks has their own name rather than the tasl name
    Kevin Kho

    Kevin Kho

    1 year ago
    You can do
    a = DbtShellTask(all_the_kwargs)
    b = a
    b.name = xxx
    c = a
    c.name = xxx
    
    with Flow(...) as flow:
        a = DbtShellTask(name=...)(cmd=...)
        b = DbtShellTask(name=...)(cmd=...)
    or maybe
    dict_of_kwargs = {...}
    a = DbtShellTask(**dict_of_kwargs)
    dict_of_kwargs['name'] = xxx
    b = DbtShellTask(**dict_of_kwargs)
    
    with Flow(...) as flow:
        a = a(cmd=...)
        b = b(cmd=...)
    Chris White

    Chris White

    1 year ago
    Another option here is:
    campaign_details_dbt_run = dbt_task(task_args={"name": "Campaign Details"}, command='dbt run -m campaign_details')
    the special keyword
    task_args
    allows you to override init kwargs (which includes
    name
    ) when you call the task
    Madison Schott

    Madison Schott

    1 year ago
    cool, thanks!