Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synch notebook with doc #655

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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