https://prefect.io logo
Title
a

ale

09/02/2022, 11:17 AM
Hey folks 👋 I want to build a new collection with a task that execute a CLI command. Should I build the new collection by extending the
prefect-shell
one, or should I stark from scratch? If I extend
prefect-shell
, should I create my own task and use the
shell_run_command
inside my task? Quick example:
from prefect_shell import shell_run_command

@task 
def my_shell_task(command: str):
    return shell_run_command(command=command)
Would this work if I call
my_shell_task
in a flow?
🙌 1
a

alex

09/02/2022, 12:01 PM
Hey @ale! I recommend using
shell_run_command
inside tasks in your new collection. That's what we did for the dbt CLI commands in
prefect-dbt
. You can use the functionality of
shell_run_command
in another task by calling
shell_run_command.fn()
.
:upvote: 1
:thank-you: 2
a

ale

09/06/2022, 2:42 PM
In this thread, it is not recommended to use the
.fn()
approach. I’m a bit confused now 😅
a

alex

09/06/2022, 2:47 PM
It’s true that you loose orchestration and observability when you use
.fn()
, but if you’re calling
.fn()
within a task, then you’ll get orchestration observability for that task.
.fn()
is an advanced feature and acts as an escape hatch in scenarios like this, so it shouldn’t be the first thing that you reach for.
a

ale

09/06/2022, 3:46 PM
Got it, thanks @alex 🙌