-
Notifications
You must be signed in to change notification settings - Fork 7
Allow env.local to use delayed eval vars immediately, if needed
#644
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
Open
tlvu
wants to merge
4
commits into
master
Choose a base branch
from
allow_delayed_eval_usage_in_env.local
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b995b6e
allow env.local to use delayed eval vars immediately, if needed
tlvu 18b6764
CHANGES: update for eval_delayed_var()
tlvu 4f93f0c
CHANGES: simplify eval_delayed_var example (mishaschwartz feedback)
tlvu deb6c6e
README: mention eval_delayed_var (fmigneault feedback)
tlvu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,14 @@ See `env.local.example <env.local.example>`_ (:download:`download </birdhouse/en | |
| Most variables that can be set in the local environment file (``env.local`` by default) can also be specified as environment variables when running ``bin/birdhouse`` | ||
| commands. Environment variables will take precedence over those specified in the ``env.local`` file. | ||
|
|
||
| In `env.local`, if you wish to immediately use any of the delayed eval variable value, you can use `eval_delayed_var DELAYED_VAR_NAME` | ||
| to compute their value. If not, their real values are only available after `env.local` is read. If that delayed eval variable depends | ||
| on another variable that you override in `env.local`, then you should define the override before calling `eval_delayed_var`. Ex: | ||
| `JUPYTERHUB_USER_DATA_DIR` is a delayed eval var because it depends on the value of `BIRDHOUSE_DATA_PERSIST_ROOT` which can be | ||
| overridden in `env.local`. So if you need the value of `JUPYTERHUB_USER_DATA_DIR` immediately in `env.local`, you need to | ||
| `eval_delayed_var JUPYTERHUB_USER_DATA_DIR` and if you need to override `BIRDHOUSE_DATA_PERSIST_ROOT`, then you need to override it | ||
| before calling `eval_delayed_var JUPYTERHUB_USER_DATA_DIR`. | ||
|
Comment on lines
+115
to
+118
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the example be as follows? # in your env.local
export BIRDHOUSE_DATA_PERSIST_ROOT=/my/data # define dependency needed by delayed var
echo "${JUPYTERHUB_USER_DATA_DIR}" # delayed '${BIRDHOUSE_DATA_PERSIST_ROOT}/jupyterhub_user_data'
eval_delayed_var JUPYTERHUB_USER_DATA_DIR # evaluate the desired variable
echo "${JUPYTERHUB_USER_DATA_DIR}" # evaluated '/my/data/jupyterhub_user_data' |
||
|
|
||
| If the file `env.local` is somewhere else, symlink it here, next to `docker-compose.yml <docker-compose.yml>`_ (:download:`download </birdhouse/docker-compose.yml>`) because many scripts assume this location. | ||
| If autodeploy scheduler job is enabled, the folder containing the `env.local` file needs to be added to `BIRDHOUSE_AUTODEPLOY_EXTRA_REPOS`. | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this in single quotes otherwise this won't wait until the
eval_delayed_varis called in order to evaluateJUPYTERHUB_USER_DATA_DIRThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is real code that we actually use in production and it works as-is.
In
env.localit is not necessary to use single-quote becauseenv.localis always last to be read. In all otherdefault.env, you are right, we need single quote becauseenv.localcan still override those variables.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you fully override
JUPYTERHUB_USER_DATA_DIR=/my/custom/path? In that case, indeed, quotes do not really matter because the result is set as the final value you want anyway.However, if you used something like
You could let a test/staging server still set
BIRDHOUSE_DATA_PERSIST_ROOTaccordingly to different locations, after the fact, with another env file loaded as:And you wouldn't have to maintain
JUPYTERHUB_USER_DATA_DIRin each sub-env variant.It is somewhat of a niche use case since you can override anything you want with explicit definitions in the final
env.localif you prefer, but still a nice feature.