Sniffs the delivery (sniff_dataset) and writes a
fully-optioned, self-documenting YAML config: every config key appears,
detected values set live, optional settings commented out with their
defaults shown, each key documented with the same description the
validator's vocabulary uses. Duplicate header names arrive renamed
positionally (with # was "..." annotations and csv_skip: 1);
fixed-width files get a character-position ruler comment above
fwf_widths, and a packed file (no detectable boundaries) gets
explicit TODO widths that validate_config refuses to
run until filled in.
Details
Create-only. An existing config for the dataset is never
overwritten – generation aborts with dqcheckr_config_exists and the
file is untouched. Once generated, a config is owned by hand edits; to
re-sniff a changed delivery, generate under a different name (or into a
scratch directory) and diff. The write is crash-safe (emitted to a temp
file, renamed into place once complete); see the Accepted design
decisions section of the specification vignette for the residual
concurrent-generation caveat.
Examples
tmp <- file.path(tempdir(), "gen-demo")
dir.create(tmp, showWarnings = FALSE)
f <- file.path(tmp, "orders.csv")
writeLines(c("id,amount", "A1,10", "A2,20"), f)
cfg <- generate_dataset_config(f, config_dir = tmp)
#> [dqcheckr] Config written: /tmp/RtmpXCCxT9/gen-demo/orders.yml
#> Review the commented options, then check with validate_config("orders", config_dir = "/tmp/RtmpXCCxT9/gen-demo").
# A deployment needs the global config too: validate_config() (like
# run_dq_check()) requires dqcheckr.yml to be present.
generate_global_config(tmp)
#> [dqcheckr] Global config written: /tmp/RtmpXCCxT9/gen-demo/dqcheckr.yml
#> Relative snapshot_db/report_output_dir resolve against the working directory -- run from the deployment root.
validate_config("orders", config_dir = tmp)$valid
#> [1] TRUE