-
Notifications
You must be signed in to change notification settings - Fork 122
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
Include documentation for using templates in the experiment configuration file #198
Closed
gsketefian
wants to merge
2
commits into
ufs-community:develop
from
gsketefian:feature/template_vars
Closed
Changes from all commits
Commits
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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.. _TemplateVars: | ||
|
||
============================================================== | ||
Using Template Variables in the Experiment Configuration Files | ||
============================================================== | ||
The SRW App's experiment configuration system supports the use of template variables | ||
in ``config_defaults.sh`` and ``config.sh``. A template variable --- or, more briefly, | ||
a "template" --- is an experiment configuration variable that contains in its definition | ||
references to values of other variables. If the template is defined properly as | ||
described below (in particular, with single quotes), then these references will **not** | ||
be expanded (i.e. set to the values of the referenced variables) at the time the | ||
experiment's variable definitions file (``var_defns.sh``) is generated or sourced. | ||
Instead, they will be expanded and evaluated **at run time**, i.e. whenever bash's | ||
``eval`` built-in command is used on the template. The script or function that will | ||
evaluate the template must first source ``var_defns.sh`` (to define the template and | ||
possibly also variables referenced by it), then ensure that any variables referenced | ||
by the template that are not already defined in ``var_defns.sh`` get defined locally, | ||
and only then call ``eval`` to evaluate the template. | ||
|
||
As an example, consider a template named ``MY_CMD`` that is defined in ``config_defaults.sh`` | ||
(or redefined by the user in ``config.sh``) as follows: | ||
|
||
.. code-block:: none | ||
|
||
MY_CMD='cd ${some_dir}' | ||
|
||
Here, ``some_dir`` may be an experiment variable defined in ``var_defns.sh`` or a | ||
local variable defined in a script or function that will evaluate the template. Note | ||
that it is important to use single quotes on the right-hand side of the definition above; | ||
otherwise, bash will try to evaluate ``${some_dir}`` when constructing ``var_defns.sh``, | ||
which may result in an error and/or unexpected behavior (e.g. if ``${some_dir}`` is not | ||
yet defined). The experiment generation system will define ``MY_CMD`` in ``var_defns.sh`` | ||
in exactly the same way as in ``config_defaults.sh`` and/or ``config.sh``, e.g. | ||
``MY_CMD='cd ${some_dir}'``. Then the following code snippet in a script or function | ||
will evaluate the contents of ``MY_CMD`` using a locally-set value of ``some_dir``: | ||
|
||
.. code-block:: none | ||
|
||
... | ||
. var_defns.sh # Source the experiment's variable definitions file (assuming | ||
# it is in the current directory). This defines the MY_CMD | ||
# template variable (in addition to other variables). | ||
... | ||
some_dir="20200715" # Set the local variable some_dir. | ||
... | ||
eval ${MY_CMD} # Use eval to evaluate the contents of MY_CMD. The value of | ||
# some_dir specified in this file a few lines above is substituted | ||
# for ${some_dir} in MY_CMD before MY_CMD is evaluated. | ||
... | ||
|
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.. _WE2E_tests: | ||
.. _WE2Etests: | ||
|
||
================================ | ||
Workflow End-to-End (WE2E) Tests | ||
|
This file contains 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.
We'd discussed the difference between
eval ${MY_CMD}
and$(eval echo ${MY_CMD}
Which version should be documented here? Both?