The current structure for configuration was partially inherited from BAG, and generally follows this behavior:
Load up configuration from a yaml file into a dictionary
Pass around this dictionary to all the classes that needed this information
Struggle and fail to provide a sensible and flexible API to modify, extend, and read existing settings through spec files.
Solution
Move configuration to a global data structure that can be read anywhere in BPG. Settings are initialized as soon as the user calls import BPG. Since Python only allows the __init__.py in BPG to be called once per interpreter, only one config dict instance will ever exist, alleviating any synchronization problems. With this change all configuration settings can be accessed BPG-wide simply by importing BPG.run_settings and reading from that dictionary.
This methodology now allows us to use feature flags. These are global flag variables that will enable us to beta test new features, but easily disable/modify them for the general public to avoid impacting the base functionality the everyone needs.
This configuration system also allows anyone to easily add new options for their own custom plugins with no additional setup aside from reading from the desired variables in BPG.run_settings
Configuration information follows a hierarchy, where each level in the hierarchy can override settings from the previous levels:
BPG's embedded default_config.yaml
bag_config.yaml as pointed to by the BAG_CONFIG environment variable
spec file for any given generator run
Future Work
Currently BPG sometimes uses references to other yaml files for configuration, for example, for photonics_tech_config_path. This makes it difficult to override the config variables set in that file. We need to try and remove this indirection and flatten the configuration hierarchy.
Fixed #109 with this update to the configuration system. This change, along with the expansion of the command line interface allows new users to setup and use the generic technology with minimal effort.
Issue
The current structure for configuration was partially inherited from BAG, and generally follows this behavior:
Solution
Move configuration to a global data structure that can be read anywhere in BPG. Settings are initialized as soon as the user calls
import BPG
. Since Python only allows the__init__.py
inBPG
to be called once per interpreter, only one config dict instance will ever exist, alleviating any synchronization problems. With this change all configuration settings can be accessed BPG-wide simply by importingBPG.run_settings
and reading from that dictionary.feature flags
. These are global flag variables that will enable us to beta test new features, but easily disable/modify them for the general public to avoid impacting the base functionality the everyone needs.BPG.run_settings
default_config.yaml
bag_config.yaml
as pointed to by theBAG_CONFIG
environment variableFuture Work
photonics_tech_config_path
. This makes it difficult to override the config variables set in that file. We need to try and remove this indirection and flatten the configuration hierarchy.