From 8fbee8403eddeb23754b8b2b7bcd869a183f0b12 Mon Sep 17 00:00:00 2001 From: egillax Date: Tue, 23 Jan 2024 11:24:25 +0100 Subject: [PATCH] skip population creation if exists --- R/RunPlp.R | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/R/RunPlp.R b/R/RunPlp.R index a711101e6..d9621c7fa 100644 --- a/R/RunPlp.R +++ b/R/RunPlp.R @@ -268,21 +268,22 @@ runPlp <- function( }) # create the population - population <- tryCatch( - { - do.call( - createStudyPopulation, - list( - plpData = plpData, - outcomeId = outcomeId, - populationSettings = populationSettings, - population = plpData$population - ) - ) - }, + if(!is.null(plpData$population)) { + ParallelLogger::logInfo('Using existing population') + } else { + ParallelLogger::logInfo('Creating population') + population <- tryCatch({ + do.call(createStudyPopulation, + list(plpData = plpData, + outcomeId = outcomeId, + populationSettings = populationSettings, + population = plpData$population + ) + )}, error = function(e){ParallelLogger::logError(e); return(NULL)} - ) - + ) + } + if(is.null(population)){ stop('population NULL') }