Skip to content

Commit

Permalink
Synch notebook with doc
Browse files Browse the repository at this point in the history
Some doc updates from omry#606 were not fully ported to the notebook.
  • Loading branch information
odelalleau committed Mar 31, 2021
1 parent 7ff277a commit ffbcb00
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions docs/notebook/Tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,7 @@
"source": [
"## Environment variable interpolation\n",
"\n",
"Environment variable interpolation is also supported.\n",
"An environment variable is always returned as a string."
"Access to environment variables is supported using ``oc.env``."
]
},
{
Expand Down Expand Up @@ -778,7 +777,7 @@
"You can specify a default value to use in case the environment variable is not defined.\n",
"This default value can be a string or ``null`` (representing Python ``None``). Passing a default with a different type will result in an error.\n",
"\n",
"The following example sets default database passwords when ``DB_PASSWORD`` is not defined:"
"The following example falls back to default passwords when ``DB_PASSWORD`` is not defined:"
]
},
{
Expand Down Expand Up @@ -820,8 +819,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"You can automatically convert a string to its corresponding type (e.g., bool, int, float, dict, list) using `oc.decode` (which can even resolve interpolations).\n",
"This resolver also accepts ``None`` as input, in which case it returns ``None``.\n",
"Strings may be converted using ``oc.decode``:\n",
"\n",
"- Primitive values (e.g., ``\"true\"``, ``\"1\"``, ``\"1e-3\"``) are automatically converted to their corresponding type (bool, int, float)\n",
"- Dictionaries and lists (e.g., ``\"{a: b}\"``, ``\"[a, b, c]\"``) are returned as transient config nodes (DictConfig and ListConfig)\n",
"- Interpolations (e.g., ``\"${foo}\"``) are automatically resolved\n",
"- ``None`` is the only valid non-string input to ``oc.decode`` (returning ``None`` in that case)\n",
"\n",
"This can be useful for instance to parse environment variables:"
]
Expand All @@ -846,9 +849,9 @@
"cfg = OmegaConf.create(\n",
" {\n",
" \"database\": {\n",
" \"port\": '${oc.decode:${oc.env:DB_PORT}}',\n",
" \"nodes\": '${oc.decode:${oc.env:DB_NODES,null}}',\n",
" \"timeout\": '${oc.decode:${oc.env:DB_TIMEOUT,null}}',\n",
" \"port\": \"${oc.decode:${oc.env:DB_PORT}}\",\n",
" \"nodes\": \"${oc.decode:${oc.env:DB_NODES}}\",\n",
" \"timeout\": \"${oc.decode:${oc.env:DB_TIMEOUT,null}}\",\n",
" }\n",
" }\n",
")\n",
Expand Down

0 comments on commit ffbcb00

Please sign in to comment.