Skip to content

Commit

Permalink
Add pre-commit hook to check that the data dict is up to date with pa…
Browse files Browse the repository at this point in the history
…rams
  • Loading branch information
jeancochrane committed Jan 9, 2025
1 parent 65cd2eb commit 46c163b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ repos:
entry: Cannot commit .Rhistory, .RData, .Rds or .rds.
language: fail
files: '\.(Rhistory|RData|Rds|rds)$'
- id: check-data-dict
name: Data dictionary must be up to date
entry: Rscript R/hooks/check-data-dict.R
files: (^|/)((params\.yaml)|(data-dict\.csv))$
language: system
9 changes: 9 additions & 0 deletions R/hooks/check-data-dict.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env Rscript
# Script to check that the data dictionary file is up to date with the
# latest feature set
library(readr)
library(yaml)

params <- read_yaml("params.yaml")
data_dict <- read_csv("docs/data-dict.csv", show_col_types = FALSE)
stopifnot(setequal(data_dict$variable_name, params$model$predictor$all))

0 comments on commit 46c163b

Please sign in to comment.