dictation-toolbox / natlinkcore

Other
4 stars 4 forks source link

Loading too much during imports #44

Open dougransom opened 1 year ago

dougransom commented 1 year ago

There are places where config files are ready during import. this is from natlinkstatus.py

_config_locations = loader.config_locations() Logger.debug(f"{__file__} Configugure {_config_locations}") Config = config.NatlinkConfig.from_first_found_file(_config_locations) Logger.debug(f"{__file__} Config {Config}") natlinkmain = loader.NatlinkMain(Logger, Config)

It makes it somewhat difficult to write code (especially tests) which might specify a config file and use the code. They don't have a chance to specify the config file because they need to import natlinkcore files for the python to compile.

I would think we should try and find a way to load the config files later, after the import.

dougransom commented 1 year ago

I made the changes here https://github.com/dougransom/natlinkcore/commit/d9ef89c43d1270614ffed84fe6d2ba1628f5451b. @quintijn can you take a quick look make sure they seem ok please?