Skip to content

Commit 685f5db

Browse files
committed
Allow parameterization of R future strategy
1 parent 63474a3 commit 685f5db

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

singlecell/resources/chunks/Functions.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,21 @@ readSeuratRDS <- function(filePath) {
173173
return(seuratObj)
174174
}
175175

176-
print('Updating future.globals.maxSize')
177-
options(future.globals.maxSize = Inf)
178-
179-
options('Seurat.memsafe' = TRUE, future.globals.onReference = "warning")
176+
options(future.globals.maxSize = Inf, future.globals.onReference = "warning")
177+
options('Seurat.memsafe' = TRUE)
180178

181179
if (Sys.getenv('SEURAT_MAX_THREADS') != '') {
182-
print(paste0('Setting future::plan workers to: ', Sys.getenv('SEURAT_MAX_THREADS')))
180+
logger::log_info(paste0('Setting future::plan workers to: ', Sys.getenv('SEURAT_MAX_THREADS')))
183181
mt <- as.integer(Sys.getenv('SEURAT_MAX_THREADS'))
184182
if (is.na(mt)) {
185183
stop(paste0('SEURAT_MAX_THREAD is not an integer: ', mt <- Sys.getenv('SEURAT_MAX_THREADS')))
186184
}
187185

188-
future::plan(strategy='multisession', workers=mt)
186+
fs <- ifelse(exists('futureStrategy'), yes = get('futureStrategy'), no = 'multicore')
187+
if (mt == 1) {
188+
fs <- 'sequential'
189+
}
190+
logger::log_info(paste0('Setting future::strategy to: ', fs))
191+
192+
future::plan(strategy = fs, workers = mt)
189193
}

0 commit comments

Comments
 (0)