From f5f678b2b46bea4543b19abcd8ece5ab1f513d0f Mon Sep 17 00:00:00 2001 From: Anthony Sena Date: Wed, 4 Dec 2024 15:54:11 -0500 Subject: [PATCH] Adding option to override database thread settings for CM & SCCS --- R/Module-CohortMethod.R | 8 ++++++++ R/Module-SelfControlledCaseSeries.R | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/R/Module-CohortMethod.R b/R/Module-CohortMethod.R index 619fc2c7..f6521b55 100644 --- a/R/Module-CohortMethod.R +++ b/R/Module-CohortMethod.R @@ -23,6 +23,14 @@ CohortMethodModule <- R6::R6Class( jobContext <- private$jobContext multiThreadingSettings <- CohortMethod::createDefaultMultiThreadingSettings(jobContext$moduleExecutionSettings$maxCores) + # Provide hook to allow for overriding the number of threads + # used for database operations + getDbCohortMethodDataThreads <- as.integer(getOption("strategus.CohortMethodModule.getDbCohortMethodDataThreads")) + if (isTRUE(getDbCohortMethodDataThreads > 0)) { + private$.message(paste0("Detected strategus.CohortMethodModule.getDbCohortMethodDataThreads - setting value to: ", getDbCohortMethodDataThreads)) + multiThreadingSettings$getDbCohortMethodDataThreads <- getDbCohortMethodDataThreads + } + args <- jobContext$settings args$connectionDetails <- connectionDetails args$cdmDatabaseSchema <- jobContext$moduleExecutionSettings$cdmDatabaseSchema diff --git a/R/Module-SelfControlledCaseSeries.R b/R/Module-SelfControlledCaseSeries.R index a5b53776..fda82d3a 100644 --- a/R/Module-SelfControlledCaseSeries.R +++ b/R/Module-SelfControlledCaseSeries.R @@ -25,6 +25,14 @@ SelfControlledCaseSeriesModule <- R6::R6Class( jobContext <- private$jobContext sccsMultiThreadingSettings <- SelfControlledCaseSeries::createDefaultSccsMultiThreadingSettings(jobContext$moduleExecutionSettings$maxCores) + # Provide hook to allow for overriding the number of threads + # used for database operations + getDbSccsDataThreads <- as.integer(getOption("strategus.SelfControlledCaseSeriesModule.getDbSccsDataThreads")) + if (isTRUE(getDbSccsDataThreads > 0)) { + private$.message(paste0("Detected strategus.SelfControlledCaseSeriesModule.getDbSccsDataThreads - setting value to: ", getDbSccsDataThreads)) + sccsMultiThreadingSettings$getDbSccsDataThreads <- getDbSccsDataThreads + } + args <- jobContext$settings args$connectionDetails <- connectionDetails args$cdmDatabaseSchema <- jobContext$moduleExecutionSettings$cdmDatabaseSchema