<@ULVA73B9P> when i set a cron job for a prefect f...
# marvin-in-the-wild
t
@Marvin when i set a cron job for a prefect flow that takes a pydantic model as input, it doesn't use the default values from the pydantic model. How should i make sure the deployed flow does this? do i need to explicitly pass them through as parameters?
m
To ensure that your deployed Prefect flow uses the default values from a Pydantic model when triggered by a cron job, the main approach is to explicitly pass the parameters through in the deployment configuration. Here's a high-level summary of what you should do: 1. Define Default Parameters: When you define the deployment for your Prefect flow, include the default values for the parameters expected by the flow function. 2. Edit Parameters in Deployment Configuration: You can specify these parameters in your deployment configuration file (e.g.,
deployment.yaml
) or update the deployment via the Prefect UI. For Prefect 2.x, you can set default parameters directly in your deployment configuration:
Copy code
yaml
parameters:
  name: "Default Name"
  num: 42
For Prefect 3.x, ensure you set the default values in your deployment file, so all future runs will inherit these defaults unless overridden:
Copy code
yaml
deployments:
  - name: my_flow_deployment
    parameters:
      param1: "default_value1"
      param2: "default_value2"
    schedules:
      - cron: "0 0 * * *"
### Key Points to Note - Edit via Prefect UI: You can also modify default parameters via the Prefect UI. Go to the deployment details page, select "Edit," and alter the parameters accordingly. - *Pass kwargs*: If you want to pass keyword arguments dynamically, structure them as JSON key-value pairs in the deployment configuration. For further details on scheduling and deployment parameters, you can refer to the documentation: - Prefect 2.x Schedules: Prefect 2.x Scheduling - Prefect 3.x Schedules: Prefect 3.x Scheduling - Prefect 3.x Deployment: Prefect 3.x Deployment Using these steps will ensure that your flow uses the default values defined in your Pydantic model, making the deployment reliable and consistent.