From 06ca01de43887105fbb1be35eeef466bc164cdfc Mon Sep 17 00:00:00 2001 From: Anthony Sena Date: Tue, 5 Sep 2023 11:23:36 -0400 Subject: [PATCH] Add integer treatment settings for DatabaseConnector to execution settings --- R/RunModule.R | 2 ++ R/Settings.R | 20 ++++++++++++++++++-- man/createCdmExecutionSettings.Rd | 6 ++++++ man/createResultsExecutionSettings.Rd | 8 +++++++- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/R/RunModule.R b/R/RunModule.R index 8b1b769e..72c02f59 100644 --- a/R/RunModule.R +++ b/R/RunModule.R @@ -88,6 +88,8 @@ runModule <- function(analysisSpecifications, keyringSettings, moduleIndex, exec options(andromedaTempFolder = file.path(jobContext$moduleExecutionSettings$workFolder, 'andromedaTemp')) options(tempEmulationSchema = jobContext$moduleExecutionSettings$tempEmulationSchema) + options(databaseConnectorIntegerAsNumeric = jobContext$moduleExecutionSettings$integerAsNumeric) + options(databaseConnectorInteger64AsNumeric = jobContext$moduleExecutionSettings$integer64AsNumeric) if (Sys.getenv('FORCE_RENV_USE', '') == 'TRUE') { renv::use(lockfile = 'renv.lock') diff --git a/R/Settings.R b/R/Settings.R index e402fb28..fe2a72f3 100644 --- a/R/Settings.R +++ b/R/Settings.R @@ -92,6 +92,8 @@ addModuleSpecifications <- function(analysisSpecifications, moduleSpecifications #' @param resultsFolder A folder in the local file system where the module output will be written. #' @param minCellCount The minimum number of subjects contributing to a count before it can be included #' in results. +#' @param integerAsNumeric Logical: should 32-bit integers be converted to numeric (double) values? If FALSE 32-bit integers will be represented using R's native `Integer` class. Default is TRUE +#' @param integer64AsNumeric Logical: should 64-bit integers be converted to numeric (double) values? If FALSE 64-bit integers will be represented using `bit64::integer64`. Default is TRUE #' @param resultsConnectionDetailsReference A string that can be used to retrieve the results database connection #' details from a secure local store. #' @param resultsDatabaseSchema A schema where the results tables are stored @@ -108,6 +110,8 @@ createCdmExecutionSettings <- function(connectionDetailsReference, workFolder, resultsFolder, minCellCount = 5, + integerAsNumeric = getOption("databaseConnectorIntegerAsNumeric", default = TRUE), + integer64AsNumeric = getOption("databaseConnectorInteger64AsNumeric", default = TRUE), resultsConnectionDetailsReference = NULL, resultsDatabaseSchema = NULL) { errorMessages <- checkmate::makeAssertCollection() @@ -118,6 +122,8 @@ createCdmExecutionSettings <- function(connectionDetailsReference, checkmate::assertCharacter(workFolder, len = 1, add = errorMessages) checkmate::assertCharacter(resultsFolder, len = 1, add = errorMessages) checkmate::assertInt(minCellCount, add = errorMessages) + checkmate::assertLogical(integerAsNumeric, max.len = 1, add = errorMessages) + checkmate::assertLogical(integer64AsNumeric, max.len = 1, add = errorMessages) checkmate::assertCharacter(resultsConnectionDetailsReference, null.ok = TRUE, add = errorMessages) checkmate::assertCharacter(resultsDatabaseSchema, null.ok = TRUE, add = errorMessages) checkmate::reportAssertions(collection = errorMessages) @@ -131,6 +137,8 @@ createCdmExecutionSettings <- function(connectionDetailsReference, workFolder = workFolder, resultsFolder = resultsFolder, minCellCount = minCellCount, + integerAsNumeric = integerAsNumeric, + integer64AsNumeric = integer64AsNumeric, resultsConnectionDetailsReference = resultsConnectionDetailsReference, resultsDatabaseSchema = resultsDatabaseSchema ) @@ -147,6 +155,8 @@ createCdmExecutionSettings <- function(connectionDetailsReference, #' @param resultsFolder A folder in the local file system where the module output will be written. #' @param minCellCount The minimum number of subjects contributing to a count before it can be included #' in results. +#' @param integerAsNumeric Logical: should 32-bit integers be converted to numeric (double) values? If FALSE 32-bit integers will be represented using R's native `Integer` class. Default is TRUE +#' @param integer64AsNumeric Logical: should 64-bit integers be converted to numeric (double) values? If FALSE 64-bit integers will be represented using `bit64::integer64`. Default is TRUE #' #' @return #' An object of type `ExecutionSettings`. @@ -156,13 +166,17 @@ createResultsExecutionSettings <- function(resultsConnectionDetailsReference, resultsDatabaseSchema, workFolder, resultsFolder, - minCellCount = 5) { + minCellCount = 5, + integerAsNumeric = getOption("databaseConnectorIntegerAsNumeric", default = TRUE), + integer64AsNumeric = getOption("databaseConnectorInteger64AsNumeric", default = TRUE)) { errorMessages <- checkmate::makeAssertCollection() checkmate::assertCharacter(resultsConnectionDetailsReference, len = 1, add = errorMessages) checkmate::assertCharacter(resultsDatabaseSchema, len = 1, add = errorMessages) checkmate::assertCharacter(workFolder, len = 1, add = errorMessages) checkmate::assertCharacter(resultsFolder, len = 1, add = errorMessages) checkmate::assertInt(minCellCount, add = errorMessages) + checkmate::assertLogical(integerAsNumeric, max.len = 1, add = errorMessages) + checkmate::assertLogical(integer64AsNumeric, max.len = 1, add = errorMessages) checkmate::reportAssertions(collection = errorMessages) executionSettings <- list( @@ -170,7 +184,9 @@ createResultsExecutionSettings <- function(resultsConnectionDetailsReference, resultsDatabaseSchema = resultsDatabaseSchema, workFolder = workFolder, resultsFolder = resultsFolder, - minCellCount = minCellCount + minCellCount = minCellCount, + integerAsNumeric = integerAsNumeric, + integer64AsNumeric = integer64AsNumeric ) class(executionSettings) <- c("ResultsExecutionSettings", "ExecutionSettings") return(executionSettings) diff --git a/man/createCdmExecutionSettings.Rd b/man/createCdmExecutionSettings.Rd index 97f05fa3..d4a84cf1 100644 --- a/man/createCdmExecutionSettings.Rd +++ b/man/createCdmExecutionSettings.Rd @@ -13,6 +13,8 @@ createCdmExecutionSettings( workFolder, resultsFolder, minCellCount = 5, + integerAsNumeric = getOption("databaseConnectorIntegerAsNumeric", default = TRUE), + integer64AsNumeric = getOption("databaseConnectorInteger64AsNumeric", default = TRUE), resultsConnectionDetailsReference = NULL, resultsDatabaseSchema = NULL ) @@ -40,6 +42,10 @@ connection details) will need to have read access to this database schema.} \item{minCellCount}{The minimum number of subjects contributing to a count before it can be included in results.} +\item{integerAsNumeric}{Logical: should 32-bit integers be converted to numeric (double) values? If FALSE 32-bit integers will be represented using R's native \code{Integer} class. Default is TRUE} + +\item{integer64AsNumeric}{Logical: should 64-bit integers be converted to numeric (double) values? If FALSE 64-bit integers will be represented using \code{bit64::integer64}. Default is TRUE} + \item{resultsConnectionDetailsReference}{A string that can be used to retrieve the results database connection details from a secure local store.} diff --git a/man/createResultsExecutionSettings.Rd b/man/createResultsExecutionSettings.Rd index 7ecc214a..d4ea9657 100644 --- a/man/createResultsExecutionSettings.Rd +++ b/man/createResultsExecutionSettings.Rd @@ -9,7 +9,9 @@ createResultsExecutionSettings( resultsDatabaseSchema, workFolder, resultsFolder, - minCellCount = 5 + minCellCount = 5, + integerAsNumeric = getOption("databaseConnectorIntegerAsNumeric", default = TRUE), + integer64AsNumeric = getOption("databaseConnectorInteger64AsNumeric", default = TRUE) ) } \arguments{ @@ -24,6 +26,10 @@ details from a secure local store.} \item{minCellCount}{The minimum number of subjects contributing to a count before it can be included in results.} + +\item{integerAsNumeric}{Logical: should 32-bit integers be converted to numeric (double) values? If FALSE 32-bit integers will be represented using R's native \code{Integer} class. Default is TRUE} + +\item{integer64AsNumeric}{Logical: should 64-bit integers be converted to numeric (double) values? If FALSE 64-bit integers will be represented using \code{bit64::integer64}. Default is TRUE} } \value{ An object of type \code{ExecutionSettings}.