RMI-PACTA/workflow.data.preparation

consider using imported parameters directly from the `config` object, rather than copying them to global environment

cjyetman opened this issue · 1 comments

Currently, parameters imported from the config.yml are copied into global variables one-by-one here, and then used via these global variables. It may be preferable to access the parameters directly from the config object rather than creating numerous global variables. e.g.

change this...

data_prep_outputs_path <- config$data_prep_outputs_path

...

currencies_data_path <- file.path(data_prep_outputs_path, "currencies.rds")

to this...

currencies_data_path <- file.path(config[["data_prep_outputs_path"]], "currencies.rds")

I'm all for this. Noting that where we currently do the conversion from config elements to top-level R objects (x <- config$x) should be replaced with a check that the elements we are using exist in the config, as a way to preserve fail-fast behavior

expected_keys <- c(
  "asset_impact_data_path",
  "factset_data_path",
  "data_prep_outputs_path",
  ...
)
stopifnot(all(expected_keys %in% names(config)))