Skip to content

Commit

Permalink
Requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
spxiwh committed Aug 30, 2023
1 parent 77189cf commit acb7697
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
32 changes: 20 additions & 12 deletions docs/workflow/initialization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,6 @@ If a particular code (let's say inspiral) wants to use an option supplied in the
[inspiral-v1]
channel-name = ${workflow|v1-channel}

We also have access to anything specified in the environment when the workflow
is generated. Environment variables can be accessed in the configuration file
like::

[inspiral-h1]
channel-name = ${os_env_vals|H1_CHANNEL_NAME}
which would take the value from `${H1_CHANNEL_NAME}` in the environment. These
variables will also be written out in the config file produced when generating
a workflow, so that you can see what environment was set when the workflow was
generated.

Similar macros can be added as needed, but these should be limited to avoid namespace confusion.

------------------------------------
Expand All @@ -282,6 +270,26 @@ Example complete workflow .ini file

Please see individual workflow documentation pages for some examples of complete .ini files and example workflows.

===========================
Other special sections
===========================

------------------------------
[environment] section
------------------------------

We have access to environment variables present when generating the workflow (with the exception of any variable containing a `$` or a `%` as these are special characters). These are automatically accessed and stored in the `[environment]` section of the config file when creating a PyCBC ConfigParser object.

Values in this section can be accessed in the configuration file like this::

[inspiral-h1]
channel-name = ${environment|H1_CHANNEL_NAME}

which would take the value from `${H1_CHANNEL_NAME}` in the environment.

These values will also be written out for later reference in the config file produced when generating a workflow.


========================
[sharedoptions] section
========================
Expand Down
7 changes: 4 additions & 3 deletions pycbc/types/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,17 @@ def __init__(
self.optionxform = str

# Add in environment
# We allow access to environment variables by adding them into the
# os_env_vals section of the config file.
# We allow access to environment variables by loading them into a
# special configparser section ([environment]) which can then
# be referenced by other sections.
# We cannot include environment variables containing characters
# that are special to ConfigParser. So any variable containing a % or a
# $ is ignored.
env_vals = {
key: value for key, value in os.environ.items()
if '%' not in value and '$' not in value
}
self.read_dict({'os_env_vals': env_vals})
self.read_dict({'environment': env_vals})

self.read_ini_file(configFiles)

Expand Down

0 comments on commit acb7697

Please sign in to comment.