diff --git a/docs/workflow/initialization.rst b/docs/workflow/initialization.rst index d2483c6f2b0..d2ba7dbe255 100644 --- a/docs/workflow/initialization.rst +++ b/docs/workflow/initialization.rst @@ -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. ------------------------------------ @@ -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 ======================== diff --git a/pycbc/types/config.py b/pycbc/types/config.py index ce584e75d79..89d579c65de 100644 --- a/pycbc/types/config.py +++ b/pycbc/types/config.py @@ -103,8 +103,9 @@ 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. @@ -112,7 +113,7 @@ def __init__( 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)