Skip to content

Commit

Permalink
Adds support for CHATTR_MODEL
Browse files Browse the repository at this point in the history
  • Loading branch information
edgararuiz committed Apr 10, 2024
1 parent 95b0404 commit 86c1681
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions R/chattr-defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,23 @@ chattr_defaults <- function(type = "default",
if (force) {
ch_env$defaults <- NULL
}

env_model <- NULL
if (is.null(chattr_defaults_get(type))) {

# Overrides environment variable if YAML file is present
if (file_exists(yaml_file)) {
check_files <- yaml_file
} else {
check_files <- ch_package_file(Sys.getenv("CHATTR_USE", unset = NA))
}

env_model <- Sys.getenv("CHATTR_MODEL", unset = NA)
if(is.na(env_model)) {
env_model <- NULL
}
for (j in seq_along(check_files)) {
td_defaults <- read_yaml(file = check_files[j])
loaded_default <- chattr_defaults_get(type = "default")
td_defaults$default <- loaded_default %||% td_defaults$default
td_defaults$default[["model"]] <- env_model %||% td_defaults$default[["model"]]
check_defaults <- c("default", type)
for (i in seq_along(check_defaults)) {
td <- td_defaults[[check_defaults[i]]]
Expand Down
4 changes: 3 additions & 1 deletion R/chattr-use.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ use_switch <- function(..., .file) {
}

ch_package_file <- function(x) {
if(is.na(x)) return(NULL)
if (is.na(x)) {
return(NULL)
}
env_folder <- ifelse(x == "test", "apptest", "configs")
package_file(env_folder, path_ext_set(x, "yml"))
}

0 comments on commit 86c1681

Please sign in to comment.