diff --git a/404.html b/404.html index 4ad7fc8..cd61eac 100644 --- a/404.html +++ b/404.html @@ -13,8 +13,8 @@ - - + + diff --git a/articles/config.html b/articles/config.html index d36f654..a1932a0 100644 --- a/articles/config.html +++ b/articles/config.html @@ -14,8 +14,8 @@ - - + + @@ -112,13 +112,13 @@

Usage

config.yml

-
default:
-  trials: 5
-  dataset: "data-sampled.csv"
-  
-production:
-  trials: 30
-  dataset: "data.csv"
+
default:
+  trials: 5
+  dataset: "data-sampled.csv"
+  
+production:
+  trials: 30
+  dataset: "data.csv"

To read configuration values you call the config::get function, which returns a list containing all of the values for the currently active configuration:

diff --git a/articles/index.html b/articles/index.html index c40fbc2..a88129a 100644 --- a/articles/index.html +++ b/articles/index.html @@ -1,5 +1,5 @@ -Articles • configArticles • config diff --git a/articles/inheritance.html b/articles/inheritance.html index ce4c662..e7c69e2 100644 --- a/articles/inheritance.html +++ b/articles/inheritance.html @@ -14,8 +14,8 @@ - - + + @@ -105,12 +105,12 @@

Defaults and inheritance config.yml

-
default:
-  trials: 5
-  dataset: "data-sampled.csv"
-  
-production:
-  dataset: "data.csv"
+
default:
+  trials: 5
+  dataset: "data-sampled.csv"
+  
+production:
+  dataset: "data.csv"

R

@@ -129,17 +129,17 @@

Defaults and inheritance config.yml

-
default:
-  trials: 5
-  dataset: "data-sampled.csv"
-
-test:
-  trials: 30
-  dataset: "data-test.csv"
-  
-production:
-  inherits: test
-  dataset: "data.csv"
+
default:
+  trials: 5
+  dataset: "data-sampled.csv"
+
+test:
+  trials: 30
+  dataset: "data-test.csv"
+  
+production:
+  inherits: test
+  dataset: "data.csv"

R

@@ -164,15 +164,15 @@

Using R code inside the yaml file config.yml

-
default:
-  cores: 2
-  debug: true
-  server: "localhost:5555"
-   
-production:
-  cores: !expr getOption("mc.cores")
-  debug: !expr Sys.getenv("ENABLE_DEBUG") == "1"
-  server: !expr config::get("server", file = "etc/server-config.yml")
+
default:
+  cores: 2
+  debug: true
+  server: "localhost:5555"
+   
+production:
+  cores: !expr getOption("mc.cores")
+  debug: !expr Sys.getenv("ENABLE_DEBUG") == "1"
+  server: !expr config::get("server", file = "etc/server-config.yml")

The default result:

R @@ -203,16 +203,16 @@

Referencing previously assig

config.yml

-
default:
-  file: "data.csv"
-
-test:
-  data_dir: "test/out"
-  dataset: !expr file.path(data_dir, file)
-  
-production:
-  data_dir: "production/out"
-  dataset: !expr file.path(data_dir, file)
+
default:
+  file: "data.csv"
+
+test:
+  data_dir: "test/out"
+  dataset: !expr file.path(data_dir, file)
+  
+production:
+  data_dir: "production/out"
+  dataset: !expr file.path(data_dir, file)

R

@@ -258,10 +258,10 @@

A valid example config.yml

-
default:
-  filename: "trials.csv"
-  folder: "some/path"
-  location: !expr file.path(folder, filename)
+
default:
+  filename: "trials.csv"
+  folder: "some/path"
+  location: !expr file.path(folder, filename)

R

@@ -277,10 +277,10 @@

An invalid example config.yml

-
default:
-  filename: "trials.csv"
-  folder: !expr c("some/path")
-  location: !expr file.path(folder, filename)
+
default:
+  filename: "trials.csv"
+  folder: !expr c("some/path")
+  location: !expr file.path(folder, filename)

R

diff --git a/articles/rsconnect.html b/articles/rsconnect.html index 8a2f55c..b043ffd 100644 --- a/articles/rsconnect.html +++ b/articles/rsconnect.html @@ -14,8 +14,8 @@ - - + + @@ -105,13 +105,13 @@

config.yml

-
default:
-  trials: 5
-  dataset: "data-sampled.csv"
-  
-rsconnect:
-  trials: 30
-  dataset: "data.csv"
+
default:
+  trials: 5
+  dataset: "data-sampled.csv"
+  
+rsconnect:
+  trials: 30
+  dataset: "data.csv"

Note: this value can be configured by your system administrator, so check your own system configuration! See https://docs.posit.co/connect/admin/appendix/configuration/#R.ConfigActive for detail.

@@ -134,20 +134,20 @@

Using config for

config.yml

-
default:
-  trials: 5
-  dataset: "data-sampled.csv"
-
-rsconnect:
-  trials: 30
-  
-rsconnect-staging:
-  inherits: rsconnect
-  dataset: "data-staging.csv"
-  
-rsconnect-prod:
-  inherits: rsconnect
-  dataset: "data.csv"
+
default:
+  trials: 5
+  dataset: "data-sampled.csv"
+
+rsconnect:
+  trials: 30
+  
+rsconnect-staging:
+  inherits: rsconnect
+  dataset: "data-staging.csv"
+  
+rsconnect-prod:
+  inherits: rsconnect
+  dataset: "data.csv"

Note that this configuration uses the inheritance of config yaml files, by having a common configuration for rsconnect and staging and prod configurations that inherit @@ -158,12 +158,17 @@

Using config for s

You may have the use case that you use the same Connect instance to host two instances of your app, for staging (test) and production.

-

In this use case you will soon run into the problem that an -individual user can not change the the environment variable -R_CONFIG_ACTIVE, since this is configured system-wide by -the administrator.

-

But you can still use config to set different values for -staging and prod, by changing the environment variable that +

The May +2023 release of Connect added support for allowing users to override +the value of R_CONFIG_ACTIVE.

+

If using a version of Connect newer than 2023.05.0, you +can change the value of R_CONFIG_ACTIVE using the +envVars argument of rsconnect::deployApp() +or the Connect +Server API.

+

If using a version of Connect less than or equal to +2023.05.0, you can use config to set different +values for staging and prod, by changing the environment variable that config::get() looks at.

Specifically, you must specify a different config argument to config::get(). For example, you can create a @@ -185,20 +190,20 @@

Using config for s

config.yml

-
default:
-  trials: 5
-  dataset: "data-sampled.csv"
-
-rsconnect:
-  trials: 30
-  
-staging:
-  inherits: rsconnect
-  dataset: "data-staging.csv"
-  
-prod:
-  inherits: rsconnect
-  dataset: "data.csv"
+
default:
+  trials: 5
+  dataset: "data-sampled.csv"
+
+rsconnect:
+  trials: 30
+  
+staging:
+  inherits: rsconnect
+  dataset: "data-staging.csv"
+  
+prod:
+  inherits: rsconnect
+  dataset: "data.csv"

If you configure the environment variable correctly, you should get the appropriate dataset values for staging (data-staging.csv) and prod (data.csv):

diff --git a/authors.html b/authors.html index f896e8d..cba0707 100644 --- a/authors.html +++ b/authors.html @@ -1,5 +1,5 @@ -Authors and Citation • configAuthors and Citation • config @@ -74,15 +74,16 @@

Authors

Citation

Source: DESCRIPTION

-

Allaire J (2023). +

Allaire J (2024). config: Manage Environment Specific Configuration Values. -https://rstudio.github.io/config/, https://github.com/rstudio/config. +R package version 0.3.2.9000, https://github.com/rstudio/config, https://rstudio.github.io/config/.

@Manual{,
   title = {config: Manage Environment Specific Configuration Values},
   author = {JJ Allaire},
-  year = {2023},
-  note = {https://rstudio.github.io/config/, https://github.com/rstudio/config},
+  year = {2024},
+  note = {R package version 0.3.2.9000, https://github.com/rstudio/config},
+  url = {https://rstudio.github.io/config/},
 }