Keeping contracts in YAML files separates the definition of “valid data” from the code that checks it. The files are easy to read, can be reviewed and versioned like any other change, and can be shared between the teams that produce and consume a dataset. This method loads such a file into a Contract, ready to use with validate() or a Pipeline.
The file can hold the contract under a top-level contract: key, as to_yaml() writes it, or have the contract fields at the top level. The fields are the contract’s parameter names (see from_dict() for the expected structure). A hand-written contract file might look like this:
The report label, Contract: payments v1.0.0, comes from the file. The payment with an amount of 0.0 fails the col_vals_gt step and triggers the warning threshold.