BBN-Q/QGL

make location of 'config.json' configurable

Closed this issue · 4 comments

Reported by Robert McGurrin:

When QGL is imported, config.json is read from the QGL package's directory (see QGL/config.py). I'd like to change this so that the config.json file can be read from alternate locations.

I'd like to add the capability of loading the config.json file from the user's local directory if it exists: otherwise the default config.json file should be loaded from the QGL/config.py when the package is loaded.

I'd also like to add the capability for the User to specify the config file using a function like:
config('/somepath/config.json')

The purpose of these changes is to make it easier for the user to change configurations.

I put together a simple approach to solving this problem, but it doesn't work properly with unittest because it only sets the path once (and then it stays set to that value for all subsequent tests).

I would imagine that this sort of issue has come up before, so I'm going to see if I can find a ready-made solution. Alternatively, we can live without unit tests for this feature.

In terms of hacked-together solutions, we could create a test script for this feature that gets run as a subprocess in the main unittest suite.

Yes, shelling out to a subprocess would do it, I think.

Resolved by 6aaca50