DEV Community

Bryce Seefieldt
Bryce Seefieldt

Posted on

NeoGPT PR merge achieved

I have worked my way through the scope of contributions I set out to make with the NeoGPT open source project. It has been a positive experience and went a great deal smoother than some past contribution work. This is primarily due to the authors engaging in the conversations around the issues posted, giving good feedback and also thoroughly reviewing changes and adding their preferences to them. This has been a surprisingly uncommon experience in my short time as an open source contributor, but I am hoping this is what I encounter more often than not in working as a community.

The 2 functions I originally setout to add to this project have both been merged into the main program and can be found in the config.py module. These functions allow users to export and import their program configuration settings to/from .yaml files.

As these settings exist in a series of global variables in the config.py file, exporting the settings was as simple as mapping the variables into an “config” object, formatted such that could be passed to the yaml.dump() function which would write the config object to a YAML file. I have found that Python has a great deal of libraries and modules available that can provide a lot of functionality that I may have previously done manually. In this case, importing the yaml and toml modules made light work of writing and reading from files. As well, the argparse module was used in this project which is one of the most helpful library tools I’ve run across. It makes light work of processing command line arguments at runtime.

The import function also used the yaml module, this time yaml.safe_load() function. This was used to read an existing yaml configuration file and load its specific values into the current settings to run the program. So similar to the export process, the object that was created using yaml.safe_load() was then mapped back to populate the global variables that represent the programs configuration settings. This turned out to be a much easier process than I realized in the beginning.

As an addition, to the scope of work I originally planned to complete, I decided that providing some unit tests for my work, would help in developing a more complete contribution process. No public facing testing code had yet been added to this projects repo, so perhaps, unit tests for these functions would be a good jumping off point to make the creation of unit tests an ongoing step in the integration of new features and contributions. Time will tell if that is the case, but I’m very happy with how my work has added to this project to date and it is very rewarding to see some substantial code contributions merged into the main project.

Top comments (0)