config icon indicating copy to clipboard operation
config copied to clipboard

Dots args to get()

Open ianmcook opened this issue 7 years ago • 2 comments

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")

ianmcook avatar Aug 22 '17 20:08 ianmcook

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".

andrie avatar Apr 05 '21 19:04 andrie

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.

ianmcook avatar Apr 05 '21 19:04 ianmcook