PYTHOMATION / adwords_reports

Pythonic wrapper of the Google AdWords API for easy reporting.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update Client class to allow setting NO_CACHE

mkirby3 opened this issue · comments

We are trying to upgrade the googleads library to v13.0.0, which now requires sqlite3 to cache some credentials when authenticating with the AdWords API. Unfortunately, the sqlite-devel linux package must be installed first in order for sqlite3 to be installed when you compile Python 3.6 (see this comment on StackOverflow: https://stackoverflow.com/questions/19530974/how-can-i-install-sqlite3-to-python). We are hesitant to reinstall and recompile Python at the moment, so would appreciate an update to the Client class in this adwords_reports library that would allow us to set the cache argument to NO_CACHE, as described in this issue from the googleads library googleads/googleads-python-lib#293 (comment).

Brian came up with the potential fix below, which might do the trick:

from

@retry(stop_max_attempt_number=3, wait_random_min=5000, wait_random_max=10000)
def _authenticate(self, credentials_path):
    logger.info("Initiating Client.")
    return adwords.AdWordsClient.LoadFromStorage(credentials_path)

to

@retry(stop_max_attempt_number=3, wait_random_min=5000, wait_random_max=10000)
def _authenticate(self, credentials_path):
    logger.info("Initiating Client.")
    adc = adwords.AdWordsClient.LoadFromStorage(credentials_path)
    adc.cache = googleads.common.ZeepServiceProxy.NO_CACHE
    return adc

Tested patch locally and it seems to work.

Lol guys, I've just discovered this issue. Glad you found a quick-fix. If you have an urgent issue rather contact me in the traditional manner instead of GitHub issues ;)

For anyone having a similar problem:
The easiest would have been to stick with the SUDS implementation of SOAP over ZEEP. This is a setting you can make in your .yaml file. In the more recent releases of googleads, Google changed the default to ZEEP.

PS: If you're hesitant on reinstalling Python on your servers you should really consider containerising your infrastructure using Docker.

Is this something you can include as a feature in the library so we don't have to keep/maintain our custom version?