rstudio / config

config package for R
https://rstudio.github.io/config/
256 stars 27 forks source link

Dots args to get() #8

Open ianmcook opened 7 years ago

ianmcook commented 7 years ago

I'm not sure if this is a good idea, but I'll throw it out here: What if config::get() could take named dots arguments and evaluate them in !expr expressions in config.yml files? This would provide a useful way to add context dependence to configuration without using environment variables.

A practical example: sparklyr::spark_connect() calls sparklyr::spark_config() which in turn calls config::get(). Say you wanted to specify Spark configuration parameters in config.yml, but make them dependent on the master argument to spark_connect(). If the master argument was passed through in the dots to config::get(), then you could have a config.yml file like this:

default:
  some.setting: !expr ifelse(master == "local", "foo", "bar")
andrie commented 3 years ago

I'm we're only responding now, but I'm doing some cleanup of old issues.

IIUC, you're suggesting to be able to evaluate expressions in the config file. This is now possible, so I suggest closing this issue.

If I misunderstand, please add some additional context about how you would call config::get() using these "dots arguments".

ianmcook commented 3 years ago

The idea is that you would call config::get(value = "some.setting", master = TRUE). Since master is not one of the formal arguments to config::get(), it would be interpreted as one of the ... (dots) arguments, and its specified value "local" would then be used to evaluate the expression.