Hey folks :wave: I want to build a new collection ...
# prefect-contributors
a
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:
Copy code
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
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
🙏 2
a
In this thread, it is not recommended to use the
.fn()
approach. I’m a bit confused now 😅
a
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
Got it, thanks @alex 🙌