DeltaE / Canada-U.S.-ElecTrade

The Role of U.S.-Canada Electricity Trade in North American Decarbonization Pathways

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Define a class to hold all the contents of the config.yaml file

Kiel-SFU opened this issue · comments

Currently, the /config/config.yaml file is called upon using many "functions.get_from_yaml()" calls throughout the codebase. For example:
regions = functions.get_from_yaml('regions_dict')

continent = functions.get_from_yaml('continent')

do_something_with_regions(regions)

do_something_with_continent(continent)

It seems like a good idea to instead add all of the /config/config.yaml values to a class in the functions.py file. This class can then be instantiated as an object in every script file that requires information from the .yaml file. Then, instead of calling the example, we could do something like:
settings = functions.YamlValues()

do_something_with_regions(settings.regions)

do_something_with_continent(settings.continent)

Where settings is the object that has member variables including "regions" and "continent". "settings" is instantiated from the class YamlValues(), which initializes itself in functions with the appropriate member variables.

The end result of this change would be cutting down on a lot of calls of functions.get_from_yaml() at the beginning of almost every function. It would also resolve this comment: #133 (review)