FullFact / health-misinfo-shared

Raphael health misinformation project, shared by Full Fact and Google
MIT License
0 stars 0 forks source link

Always call google.auth.default from inside a function #133

Closed andylolz closed 3 weeks ago

andylolz commented 3 weeks ago

google.auth.default() raises an exception if google credentials aren’t set. When this is called from outside of a function, this exception is raised on module import.

See for example: https://github.com/FullFact/health-misinfo-shared/blob/46597a4806e36077ebb331498c21ec000567cc1d/src/health_misinfo_shared/fine_tuning.py#L25

This call means if we want to import fine_tuning, we can only do it successfully if google credentials are set.

This causes a problem for unit testing, because if any bit of the code imports this module in a unit test, the unit test will fail.