<@ULVA73B9P> how to have prefect.yaml specify a de...
# ask-marvin
f
@Marvin how to have prefect.yaml specify a deployment where a specific shell script is to run on a given schedule, without defining any flows in python?
m
To define a deployment in Prefect that runs a shell script on a given schedule without defining any flows in Python, you would typically use a Prefect Deployment specification in a
prefect.yaml
file, defining the shell script as a subprocess task probably, and then setting up a schedule for it. However, the Prefect documentation primarily discusses defining deployments with Python flows, and it is not immediately clear how to specify deployments for running shell scripts directly from a
prefect.yaml
file without a flow. Deployments are generally tied to flow definitions, which are typically written in Python. For scheduling, Prefect supports cron-style scheduling. Your
prefect.yaml
could include a
schedule
key with a cron string value to define when the deployment should be run, though again, this is usually in the context of running Python flows. As the documentation on running shell scripts as deployments without defining Python flows is not directly provided, I would suggest exploring Prefect's concept of subprocess tasks within a Python flow, which can be used to execute shell scripts, and then deploying this flow with the desired schedule as indicated in the deployment setup. I will continue searching for a more specific example or guidance on defining such a deployment purely from a
prefect.yaml
configuration, but it may require at least a minimal Python flow definition to be wrapped around the shell script execution.
n
i don't believe you can do this in
prefect.yaml
at this time, but you can do
Copy code
prefect shell serve "curl <http://wttr.in/Chicago?format=3>" --flow-name "Daily Chicago Weather Report" --cron-schedule "0 9 * * *" --deployment-name "Chicago Weather"
to serve a deployment on a schedule given a CLI command
or to run it ad hoc
Copy code
» prefect shell watch "curl <http://wttr.in/Chicago?format=3>"
10:21:11.261 | INFO    | prefect.engine - Created flow run 'augmented-oarfish' for flow 'Shell Command'
10:21:12.480 | INFO    | Flow run 'augmented-oarfish' - Chicago: 🌨  +35°F
10:21:12.626 | INFO    | Flow run 'augmented-oarfish' - Finished in state Completed()
f
Thanks Nate! Are there any limitations to this, compared to a regular python flow? I am thinking about setting up dbt core to run on prefect, and it seems pretty verbose to write python to ultimately just run something like
dbt run --select model_xyz
. But maybe I am missing a point why doing it the more complicated way is better (refering to this: https://prefecthq.github.io/prefect-dbt/)
n
the
prefect shell
approach definitely lacks all the pythonic flexibility, like say send message to XYZ slack channels upon certain failure within DBT job, but the tradeoff is that its super simple and gives you basic observability prefect-dbt offers a lot more places to hook in programmatically
so it really depends on your objectives
👍 1