František
04/03/2024, 3:18 PMMarvin
04/03/2024, 3:19 PMprefect.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.Nate
04/03/2024, 3:20 PMprefect.yaml
at this time, but you can do
prefect shell serve "curl <http://wttr.in/Chicago?format=3>" --flow-name "Daily Chicago Weather Report" --cron-schedule "0 9 * * *" --deployment-name "Chicago Weather"
Nate
04/03/2024, 3:21 PMNate
04/03/2024, 3:21 PM» 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()
František
04/03/2024, 3:26 PMdbt 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/)Nate
04/03/2024, 3:30 PMprefect 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 programmaticallyNate
04/03/2024, 3:31 PM