OpenEnergyPlatform / open-MaStR

A collaborative software to download the energy database Marktstammdatenregister (MaStR)
https://open-mastr.readthedocs.io/en/latest/
GNU Affero General Public License v3.0
87 stars 19 forks source link

Update config files if necessary #410

Closed deniztepe closed 1 year ago

deniztepe commented 1 year ago

Files in .open-mastr/config folder might be updated when a new version is available. Currently, the files or the folder must be deleted for a reinitialization.


Yes, that's right. I thought about this but wanted to tackle it in another PR before the next release as this one is really full already. A simple solution would be to remove the if not here https://github.com/OpenEnergyPlatform/open-MaStR/blob/46f51056636404e2c706ab9eb69bf164083f4d54/open_mastr/utils/config.py#L143-L151 However, this would lead to an update of the filenames.yml everytime the Mastr class is called and longer runtimes, as the function is called in setup_project_home() which is called in __init__.py. Better solutions would check for e.g. the version or include refactoring. But both options should be handled in another issue IMO.

_Originally posted by @chrwm in https://github.com/OpenEnergyPlatform/open-MaStR/pull/401#discussion_r1068289275_

chrwm commented 1 year ago

Timeit says _filenames_generator() takes in the range of 0.009 to 0.013 seconds to run on average. Thus, I'd go for the simple solution to delete the if not os.path.isfile(filenames_file): which leads to creation of the filenames.yml everytime Mastr class is called. It'd cover both objectives above. Any objections? @deniztepe

deniztepe commented 1 year ago

In this case, I would also support your suggestion. Normal use case takes anyway much longer.