From 478bb1c5eecd5d7fcbd9d0afc8c7c710db9b2ff0 Mon Sep 17 00:00:00 2001 From: Yulric Sequeira Date: Tue, 2 Jun 2026 12:55:50 -0400 Subject: [PATCH 1/2] Deduplicate column metadata between beta-coefficients and logistic-regression The two file types share the same three columns (variable, coefficient, type) so their rows in column-metadata.csv are now merged using a semicolon-separated fileName (e.g. "beta-coefficients;logistic-regression"). Co-Authored-By: Claude Opus 4.7 --- R/create-Rmd-table.R | 2 +- R/create-reference-Rmd.R | 2 +- R/matches-file-type.R | 12 ++++++++++++ R/validate-model-paramater-file.R | 6 +++--- docs/2-model-parameter-files.qmd | 1 + docs/5-reference.qmd | 1 + inst/metadata/column-metadata.csv | 9 +++------ 7 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 R/matches-file-type.R diff --git a/R/create-Rmd-table.R b/R/create-Rmd-table.R index 09fdcb0..a5bdfe8 100644 --- a/R/create-Rmd-table.R +++ b/R/create-Rmd-table.R @@ -1,5 +1,5 @@ create_Rmd_table <- function(file_type, file_metadata, column_metadata, column_category_metadata) { - column_metadata_rows <- column_metadata[column_metadata$fileName == file_type, ] + column_metadata_rows <- column_metadata[.matches_file_type(column_metadata$fileName, file_type), ] if(nrow(column_metadata_rows) == 0) { stop(glue::glue("No column metadata rows found for file {file_type}")) } diff --git a/R/create-reference-Rmd.R b/R/create-reference-Rmd.R index 498b709..f8fc205 100644 --- a/R/create-reference-Rmd.R +++ b/R/create-reference-Rmd.R @@ -43,7 +43,7 @@ create_reference_Rmd <- function( ) column_metadata_for_file <- column_metadata[ - column_metadata$fileName == file_name, + .matches_file_type(column_metadata$fileName, file_name), ] if(nrow(column_metadata_for_file) == 0) { stop(paste("No column metadata found for file", file_name)) diff --git a/R/matches-file-type.R b/R/matches-file-type.R new file mode 100644 index 0000000..6c436aa --- /dev/null +++ b/R/matches-file-type.R @@ -0,0 +1,12 @@ +#' Tests the `fileName` column in the column metadata file for the existence of +#' a file +#' +#' @param files_names the fileName column +#' @param file_type the file name to check for +#' +#' @return a logical vector +#' +#' @keywords internal +.matches_file_type <- function(file_names, file_type) { + sapply(strsplit(file_names, ";"), function(names) file_type %in% names) +} diff --git a/R/validate-model-paramater-file.R b/R/validate-model-paramater-file.R index 58c7aef..6d92e51 100644 --- a/R/validate-model-paramater-file.R +++ b/R/validate-model-paramater-file.R @@ -123,12 +123,12 @@ validate_file <- function(file, column_metadata, column_category_metadata) { current_file_metadata <- file_metadata[file_metadata$fileName == file_type,] - + if (nrow(current_file_metadata) == 0) { stop(glue::glue("No rows found in file metadata for file type {file_type}")) } - - file_column_metadata <- column_metadata[column_metadata$fileName == file_type,] + + file_column_metadata <- column_metadata[.matches_file_type(column_metadata$fileName, file_type),] if (nrow(file_column_metadata) == 0) { stop(glue::glue("No rows found in columns metadata for file type {file_type}")) } diff --git a/docs/2-model-parameter-files.qmd b/docs/2-model-parameter-files.qmd index 5f06373..7380067 100644 --- a/docs/2-model-parameter-files.qmd +++ b/docs/2-model-parameter-files.qmd @@ -1,4 +1,5 @@ ```{r echo=FALSE} +source("../R/matches-file-type.R") source("../R/create-Rmd-table.R") ``` diff --git a/docs/5-reference.qmd b/docs/5-reference.qmd index f3b161b..8083020 100644 --- a/docs/5-reference.qmd +++ b/docs/5-reference.qmd @@ -1,4 +1,5 @@ ```{r, echo=FALSE, results='asis'} +source("../R/matches-file-type.R") source("../R/create-reference-Rmd.R") file_metadata <- read.csv( diff --git a/inst/metadata/column-metadata.csv b/inst/metadata/column-metadata.csv index 0752e5a..9e3787e 100644 --- a/inst/metadata/column-metadata.csv +++ b/inst/metadata/column-metadata.csv @@ -54,9 +54,9 @@ validate,value,The value to use when applying the validation,string,FALSE,,,, validate,error_handle,How to handle failed validations,category,FALSE,,,, validate,error_replace,Value to replace variables that fail validations whose errorHandle value is warning,string,FALSE,,,, validate,location,Which step in the scoring process the validation should be used,string,FALSE,,,, -beta-coefficients,variable,The name of the variable whose beta coefficient the row contains. If this is the coefficient for the intercept then use the name "Intercept",string,FALSE,,,, -beta-coefficients,coefficient,The beta coefficient,number,FALSE,,,, -beta-coefficients,type,The statistical type of the variable,category,FALSE,,,, +beta-coefficients;logistic-regression,variable,The name of the variable whose beta coefficient the row contains. If this is the coefficient for the intercept then use the name "Intercept",string,FALSE,,,, +beta-coefficients;logistic-regression,coefficient,The beta coefficient,number,FALSE,,,, +beta-coefficients;logistic-regression,type,The statistical type of the variable,category,FALSE,,,, baseline-hazards,time,The time upto which the baseline hazard should be used,number,FALSE,,,, baseline-hazards,baselineHazard,The baseline hazard value,number,FALSE,,,, survival_bins,catValue,The bin number,number,FALSE,,,, @@ -66,6 +66,3 @@ tables,tableName,The name of the table,string,FALSE,,,, tables,tablePath,The path to the table relative to this file,string,FALSE,,,, simple-model,name,The name of the metadata,category,FALSE,,,, simple-model,value,The value of the metadata,string,FALSE,,,, -logistic-regression,variable,The name of the variable whose beta coefficient the row contains. If this is the coefficient for the intercept then use the name "Intercept",string,FALSE,,,, -logistic-regression,coefficient,The beta coefficient,number,FALSE,,,, -logistic-regression,type,The statistical type of the variable,category,FALSE,,,, From e16f3abeaa5c6589b96692e23614e667e2e2df22 Mon Sep 17 00:00:00 2001 From: Yulric Sequeira Date: Tue, 9 Jun 2026 10:35:45 -0400 Subject: [PATCH 2/2] Require quarto >= 1.9.0 for the docs project Older Quarto versions (1.3.x) don't propagate renv's R_LIBS_* env vars to post-render Rscript subprocesses, don't fire post-render hooks for file-less renders used by the generate-llms-md tests, and don't propagate post-render script errors as non-zero exit codes. Pinning a floor surfaces these incompatibilities at render time instead of as mysterious test failures. Co-Authored-By: Claude Opus 4.7 --- docs/_quarto.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/_quarto.yml b/docs/_quarto.yml index 99c3b96..e70e4c8 100644 --- a/docs/_quarto.yml +++ b/docs/_quarto.yml @@ -3,6 +3,8 @@ project: output-dir: dist post-render: ./generate_llms_script.R +quarto-required: ">=1.9.0" + website: title: "Model Parameter Files" sidebar: