mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2026-06-19 04:27:30 +02:00
fix: trying to fix launching with globals
This commit is contained in:
parent
a73f8b1ba3
commit
95fc0a4d5f
3 changed files with 20 additions and 9 deletions
|
|
@ -1 +1 @@
|
|||
hosted_version <- function()'v26.3.3-260311'
|
||||
hosted_version <- function()'v26.3.3-260312'
|
||||
|
|
|
|||
|
|
@ -43,14 +43,15 @@ launch_FreesearchR <- function(include_globalenv = TRUE,
|
|||
|
||||
## Helper to set env variables
|
||||
get_config <- function(var_name, default = NULL) {
|
||||
# First check environment variables (set by Docker)
|
||||
val <- Sys.getenv(var_name, unset = NA)
|
||||
val <- Sys.getenv(var_name, unset = NA_character_)
|
||||
|
||||
if (!is.na(val) && nzchar(val)) {
|
||||
# Only use env var if it is explicitly set and non-empty
|
||||
if (!is.na(val) && nzchar(trimws(val))) {
|
||||
if (is.logical(default)) return(to_logical(val))
|
||||
if (is.numeric(default)) return(as.numeric(val))
|
||||
return(val)
|
||||
}
|
||||
|
||||
# Fall back to default (can be overridden when launching from R)
|
||||
if (!is.null(default)) {
|
||||
return(default)
|
||||
}
|
||||
|
|
@ -58,6 +59,16 @@ get_config <- function(var_name, default = NULL) {
|
|||
stop(paste("Required config variable not set:", var_name))
|
||||
}
|
||||
|
||||
to_logical <- function(x) {
|
||||
result <- switch(tolower(trimws(as.character(x))),
|
||||
"true" = , "1" = , "yes" = TRUE,
|
||||
"false" = , "0" = , "no" = FALSE,
|
||||
NA
|
||||
)
|
||||
if (is.na(result)) stop(paste("Cannot coerce to logical:", x))
|
||||
result
|
||||
}
|
||||
|
||||
|
||||
## File loader - based on the module, uses hard coded default values
|
||||
load_file <- function(path) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue