How to run python adwords api from aws lambda and deal with your cache

512 views
Skip to first unread message

Monty808

unread,
Feb 26, 2021, 1:07:32 AM2/26/21
to AdWords API and Google Ads API Forum
Hello Google,

Google how do I run? How do deal with when what ever you are trying to cache?  How do I turn it off?  How to a change the dir where you are trying to cache?  This is urgent


[Errno 30] Read-only file system: '/home/sbx_user1051': OSError
Traceback (most recent call last):
File "/var/task/etfTemplateAutoTools.py", line 64, in etfTemplateAutoTools_handler
main(parms,environment,db_api,template_id)
File "/var/task/template_auto_tools.py", line 428, in main
tco.create()
File "/var/task/template_auto_tools.py", line 101, in create
cgto = campaign_group_object(self.adwords_client,self.CUSTOMER_SERVICE_ID,self.environment)
File "/var/task/adwords_campaign_group_tools.py", line 21, in __init__
self.campaign_group_service = adwords_client.GetService('CampaignGroupService', version=self.version)
File "/var/task/googleads/adwords.py", line 315, in GetService
cache=self.cache)
File "/var/task/googleads/common.py", line 769, in __init__
transport = _ZeepProxyTransport(timeout, proxy_config, cache)
File "/var/task/googleads/common.py", line 513, in __init__
cache = zeep.cache.SqliteCache()
File "/var/task/zeep/cache.py", line 118, in __init__
self._db_path = path if path else _get_default_cache_path()
File "/var/task/zeep/cache.py", line 181, in _get_default_cache_path
os.makedirs(path)
File "/var/lang/lib/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/var/lang/lib/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/var/lang/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/home/sbx_user1051'

Google Ads API Forum Advisor Prod

unread,
Feb 26, 2021, 5:17:06 PM2/26/21
to davidmo...@gmail.com, adwor...@googlegroups.com
Hi,

Are you using Python client library in this integration?  This doesn't look like an API generated error. I recommend checking with AWS Lambda support if it allows to write a temporary file in a directory or a location that you are trying to write.

Thanks,
Google Logo
Lakshmi Prathipati
Google Ads API Team
 


ref:_00D1U1174p._5004Q2DJCgg:ref

Monty808

unread,
Feb 26, 2021, 11:02:39 PM2/26/21
to AdWords API and Google Ads API Forum
Thanks google but for future reference, this solved the issue.  AWS lambda does but you have to change the directory of the temp files.  Changing the location or even disabling cache is not documented sufficiently.  I just went down the route of disabling for now.  Google can you outline what the consequences for disabling are?

 oauth2_client = oauth2.GoogleRefreshTokenClient(CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN)

adwords_client = adwords.AdWordsClient(DEVELOPER_TOKEN, oauth2_client, USER_AGENT,cache=googleads.common.ZeepServiceProxy.NO_CACHE)

 adwords_client.SetClientCustomerId(CUSTOMER_SERVICE_ID)

Google Ads API Forum Advisor Prod

unread,
Mar 1, 2021, 12:30:54 PM3/1/21
to davidmo...@gmail.com, adwor...@googlegroups.com
Hi,

The team is looking into this issue. One of our team members will reach out to you shortly.

Google Ads API Forum Advisor Prod

unread,
Mar 2, 2021, 9:29:37 AM3/2/21
to davidmo...@gmail.com, adwor...@googlegroups.com
Hello - 

The cache parameter is used to initialize a Zeep Transport instance, as you can see here.

Zeep's documentation on caching states that the local store is used to cache WSDL and XSD files for 1 hour. Disabling caching means that the library may make redundant requests for these resources, which could affect your overall performance depending on your use case. Given that you're using an AWS Lambda I'm assuming your process is short-lived, so disabling cache seems like it will not be a problem for you.

Hope that helps!

Best,
Ben, Google Ads API Team

ref:_00D1U1174p._5004Q2DJCgg:ref
Reply all
Reply to author
Forward
0 new messages