Package: yaml-config-wrapper
YAML Config WrapperAboutA YAML configuration
wrapper.PYPI PackageTable of ContentsUsing the libraryInstalling and using the libraryCreating a config fileSet the required environment variablesManually install the libraryPrerequisitesInstall the requirementsRun the Unit TestsContinuous IntegrationUpdate PyPI packageLicenseUsing the libraryInstalling and using the libraryFirst, you need to install the library either using pip:$pipinstallyaml_config_wrapperThen, import it and use it like so:fromyaml_config_wrapperimportConfiguration# The `config_schema_path` argument is optionalconf=Configuration(config_src='confs/template_conf.yml',config_schema_path='yml_schemas/default_schema.json')Creating a config fileThere are two already example yml configs
underconfs. An example structure
is the following:tag:productioncloudstore:config:api_key:!ENV${DROPBOX_API_KEY}type:dropboxdatastore:config:hostname:!ENV${MYSQL_HOST}username:!ENV${MYSQL_USERNAME}password:!ENV${MYSQL_PASSWORD}db_name:!ENV${MYSQL_DB_NAME}port:3306type:mysqlemail_app:config:email_address:!ENV${EMAIL_ADDRESS}api_key:!ENV${GMAIL_API_KEY}type:gmailThe!ENVflag indicates that you are passing an environmental value to this attribute. You can change
the values/environmental var names as you wish.There is also the option to create a validation schema the enforces a specific yaml structure. The
default dummy version is
thedefault_schema.jsonfile.Set the required environment variablesIn order to use the!ENVflag in you config, you need to set the corresponding environment variables
like so:$exportDROPBOX_API_KEY=123$exportMYSQL_HOST=foo.rds.amazonaws.com
$exportMYSQL_USERNAME=user
$exportMYSQL_PASSWORD=pass
$exportMYSQL_DB_NAME=Test_schema
$exportEMAIL_ADDRESS=GmailBot<foobar@gmail.com>
$exportGMAIL_API_KEY=123The best way to do that, is to create a .env
file (example),
and source it before running the code.Manually install the libraryThese instructions will get you a copy of the project up and running on your local machine for
development and testing purposes.PrerequisitesYou need to have a machine withanacondainstalled and
any Bash based shell (e.g. zsh) installed.$ conda -V
conda 4.10.1

$ echo $SHELL
/usr/bin/zshInstall the requirementsAll the installation steps are being handled by
theMakefile.First, modify the python version (min_python) and everything else you need in
thesettings.ini.Then, execute the following commands:$ make create_env
$ conda activate yaml_config_wrapper
$ make distNow you are ready to use and modify the library.Run the Unit TestsIf you want to run the unit tests, execute the following command:$ make testsContinuous IntegrationFor the continuous integration, theCircleCIservice is being used. For more information you can
check thesetup guide.Again, you should set
theabove-mentioned environmental variables(reference)
and for any modifications, edit
thecircleci config.Update PyPI packageThis is mainly for future reference for the developers of this project. First,
create a file called~/.pypircwith your pypi login details, as follows:[pypi]
username = your_pypi_username
password = your_pypi_passwordThen, modify the python version (min_python), project status (status), release version (version)
and everything else you need in
thesettings.ini.Finally, execute the following commands:$ make create_env
$ conda activate yaml_config_wrapper
$ make releaseFor a dev release, change thetesting_versionand instead ofmake release, runmake release_test.LicenseThis project is licensed under the MIT License - see
theLICENSEfile for
details.