<@ULVA73B9P> is there a way to validate a prefect ...
# ask-marvin
m
@Marvin is there a way to validate a prefect deployment yaml without actually going through the deployment? I want to add a pre-commit hook that stops commits of invalid deployment yamls. Something like a dry run deploy?
m
Currently, there isn't a built-in Prefect CLI command that provides explicit validation of a deployment YAML without performing the deployment. However, when you run
prefect deploy
with a YAML file, it does parse and validate the file as part of the deployment process. If you want to create a pre-commit hook to check the validity of Prefect deployment YAML files, you might need to write a custom script that utilizes Prefect's internal deployment parsing mechanisms (without actually triggering a deployment) or simply invoke the
prefect deploy --dry-run
(if available) to simulate a deployment. Here is a generic example of how you might use a
--dry-run
option in a CLI command for validation purposes, which is common in many CLI-based tools:
Copy code
bash
# Pseudo-command (Please check if Prefect offers a --dry-run option)
prefect deploy --dry-run -p path/to/deployment.yaml
Nonetheless, as of the information from Chroma, there was no mention of a
--dry-run
flag that could be used for deployment validation in Prefect 2.x. The official Prefect documentation or the help from the Prefect CLI itself (
prefect deploy --help
) would be the best place to find the most up-to-date information on the deployment process and any validation options. For more detailed and specific implementation, consult the Prefect documentation or Prefect community for any updates or plugins that could support this use case. If a dry-run-like feature existed, it would typically parse the YAML and check it against the expected schema without making any changes to the environment or proceeding with the deployment.
n
what about something like this? i feel like it could be improved upon a bit if it'd be used as a stable pre-commit hook, but it does mock out the actual Prefect API side effects of
prefect deploy
+ associated steps (e.g. cloning repos, building images) and replaces it with validation of each assembled deployment against our
DeploymentCreate
schema