Skip to contents

Loads project configuration from YAML and environment variables, sets up required directories, and returns a unified settings object for the weighting pipeline.

Usage

get_settings(
  reload_settings = FALSE,
  create_data_root = TRUE,
  settings_file = NULL,
  data_root = NULL,
  code_root = NULL,
  raw_data_root = NULL,
  python_env = NULL,
  envir = parent.frame(),
  print = TRUE
)

Arguments

reload_settings

logical. If TRUE, reloads the settings file even if already loaded. Default: FALSE.

create_data_root

logical. If TRUE (default), creates the data root directory if missing.

settings_file

character. Optional override for settings YAML path. Default: NULL (uses .Renviron or fallback).

data_root

character. Optional override for data root path. Default: NULL (uses .Renviron or tempdir()).

code_root

character. Optional override for code root path. Default: NULL (uses .Renviron or working dir).

python_env

character. Optional override for Python environment path. Default: NULL (uses .Renviron or YAML).

envir

environment. Where to load settings; used to check for existing settings. Default: parent.frame().

Value

list. Unified settings object with all config, paths, and options for the pipeline.

Details

  • Centralizes config management, enforces reproducibility, and ensures all downstream scripts use consistent paths and options.

  • Loads YAML config, merges with environment overrides, and creates project directories if needed.

  • Handles interactive/non-interactive sessions, supports overrides for testing/debugging.

  • Validates critical settings (e.g., unrelated_adjustment, write_to_db) and warns on misconfiguration.

  • Side effects: creates directories, sets options, may prompt user if write_to_db is TRUE.

  • Performance: minimal; only reads config and sets up environment.

  • Error handling: stops on missing files, invalid settings, or directory creation failures.

Examples

## Not run:
# Load settings from YAML and environment
Sys.setenv(WEIGHTING_SETTINGS_PATH = "configs/examples/example_settings.yaml")
settings <- get_settings()
#> Error in get_settings(): could not find function "get_settings"
settings <- get_settings(settings_file = "configs/example.yaml", reload_settings = TRUE)
#> Error in get_settings(settings_file = "configs/example.yaml", reload_settings = TRUE): could not find function "get_settings"
## End(Not run)