I am trying to get the Google AdManager API to work into a Colab notebook.
Following the instructions here I have managed to create my own configuration YAML file, uploading it into the Colab notebook and executing the basic call to the NetworkService
service. It all goes well and behaves as expected, returning the expected network name and ID.
Then I try to add some more requests like this and I get this error message:
FileNotFoundError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/googleads/common.py in LoadFromStorage(path, product_yaml_key, required_client_values, optional_product_values)
279 try:
--> 280 with open(path, 'rb') as handle:
281 yaml_doc = handle.read()
FileNotFoundError: [Errno 2] No such file or directory: '/root/googleads.yaml',
During handling of the above exception, another exception occurred:
GoogleAdsValueError Traceback (most recent call last)
<ipython-input-14-ed9b34dcaa81> in <module>()
25 if __name__ == '__main__':
26 # Initialize client object.
---> 27 ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
28 main(ad_manager_client)
/usr/local/lib/python3.6/dist-packages/googleads/ad_manager.py in LoadFromStorage(cls, path)
202 return cls(**googleads.common.LoadFromStorage(
203 path, cls._YAML_KEY, cls._REQUIRED_INIT_VALUES,
--> 204 cls._OPTIONAL_INIT_VALUES))
205
206 def __init__(self, oauth2_client, application_name, network_code=None,
/usr/local/lib/python3.6/dist-packages/googleads/common.py in LoadFromStorage(path, product_yaml_key, required_client_values, optional_product_values)
282 except IOError:
283 raise googleads.errors.GoogleAdsValueError(
--> 284 'Given yaml file, %s, could not be opened.' % path)
285
286 try:
GoogleAdsValueError: Given yaml file, /root/googleads.yaml, could not be opened.
And this despite the fact that the same yaml file uploaded in the folder of the notebook (content/googleads.yaml
) works perfectly well with the first request.
Any help appreciated.
Thanks!
PS: just to let you know, I am still in my infancy with Python.
It would be easier to help you if you included a minimal repro notebook showing what worked and what didn't. Guessing in the dark, though: the thing that worked had extra code that looks in the current directory for the YAML file, while the thing that didn't doesn't. Simplest fix might be to create a symlink like:
!ln -s /content/googleads.yaml /root/googleads.yaml