# Buggy code
def retrieve(self, model_name: Text, target_path: Text) -> None:
    """Downloads a model that has been persisted to cloud storage."""

    tar_name = self._tar_name(model_name)

    self._retrieve_tar(tar_name)
    self._decompress(tar_name, target_path)


# Traceback (google.api_core.exceptions.NotFound)
2019-07-15 09:35:24 DEBUG    google.auth.transport.requests  - Making request: POST https://oauth2.googleapis.com/token
2019-07-15 09:35:25 ERROR    rasa.core.agent  - Could not load model due to 404 GET https://www.googleapis.com/download/storage/v1/b/toto/o/models.tar.gz?alt=media: ('Request failed with status code', 404, 'Expected one of', <HTTPStatus.OK: 200>, <HTTPStatus.PARTIAL_CONTENT: 206>).
[2019-07-15 09:35:25 +0000] [1] [ERROR] Experienced exception while trying to serve
Traceback (most recent call last):
File "/usr/local/bin/rasa", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/rasa/__main__.py", line 76, in main
cmdline_arguments.func(cmdline_arguments)
File "/usr/local/lib/python3.6/site-packages/rasa/cli/run.py", line 102, in run
rasa.run(**vars(args))
File "/usr/local/lib/python3.6/site-packages/rasa/run.py", line 54, in run
**kwargs
File "/usr/local/lib/python3.6/site-packages/rasa/core/run.py", line 172, in serve_application
app.run(host="0.0.0.0", port=port)
File "/usr/local/lib/python3.6/site-packages/sanic/app.py", line 1096, in run
serve(**server_settings)
File "/usr/local/lib/python3.6/site-packages/sanic/server.py", line 742, in serve
trigger_events(before_start, loop)
File "/usr/local/lib/python3.6/site-packages/sanic/server.py", line 604, in trigger_events
loop.run_until_complete(result)
File "uvloop/loop.pyx", line 1451, in uvloop.loop.Loop.run_until_complete
File "/usr/local/lib/python3.6/site-packages/rasa/core/run.py", line 211, in load_agent_on_start
action_endpoint=endpoints.action,
File "/usr/local/lib/python3.6/site-packages/rasa/core/agent.py", line 251, in load_agent
model_server=model_server,
File "/usr/local/lib/python3.6/site-packages/rasa/core/agent.py", line 911, in load_from_remote_storage
persistor.retrieve(model_name, target_path)
File "/usr/local/lib/python3.6/site-packages/rasa/nlu/persistor.py", line 51, in retrieve
self._retrieve_tar(tar_name)
File "/usr/local/lib/python3.6/site-packages/rasa/nlu/persistor.py", line 206, in _retrieve_tar
blob.download_to_filename(target_filename)
File "/usr/local/lib/python3.6/site-packages/google/cloud/storage/blob.py", line 664, in download_to_filename
self.download_to_file(file_obj, client=client, start=start, end=end)
File "/usr/local/lib/python3.6/site-packages/google/cloud/storage/blob.py", line 638, in download_to_file
_raise_from_invalid_response(exc)
File "/usr/local/lib/python3.6/site-packages/google/cloud/storage/blob.py", line 2034, in _raise_from_invalid_response
raise exceptions.from_http_status(response.status_code, message, response=response)
google.api_core.exceptions.NotFound: 404 GET https://www.googleapis.com/download/storage/v1/b/toto/o/models.tar.gz?alt=media: ('Request failed with status code', 404, 'Expected one of', <HTTPStatus.OK: 200>, <HTTPStatus.PARTIAL_CONTENT: 206>)

# Fixed code
def retrieve(self, model_name: Text, target_path: Text) -> None:
    """Downloads a model that has been persisted to cloud storage."""

    tar_name = model_name

    if not model_name.endswith("tar.gz"):
        # ensure backward compatibility
        tar_name = self._tar_name(model_name)

    self._retrieve_tar(tar_name)
    self._decompress(tar_name, target_path)