# Buggy code
def cache_key(
    cls, component_meta: Dict[Text, Any], model_metadata: Metadata
) -> Optional[Text]:
    _config = common.update_existing_keys(cls.defaults, component_meta)
    return f"{cls.name}-{get_dict_hash(_config)}"


# Traceback (urllib.error.HTTPError)
Warning: Output is not to a terminal (fd=1).
Warning: Input is not to a terminal (fd=0).
2020-09-28 04:00:48 INFO     absl  - Using /tmp/tfhub_modules to cache modules.
2020-09-28 04:00:48 INFO     absl  - Downloading TF-Hub Module 'https://github.com/PolyAI-LDN/polyai-models/releases/download/v1.0/model.tar.gz'.
Welcome to Rasa! 🤖

To get started quickly, an initial project will be created.
If you need some help, check out the documentation at https://rasa.com/docs/rasa.

Created project directory at '/usr/src/app'.
Finished creating project structure.
Training an initial model...
The configuration for policies and pipeline was chosen automatically. It was written into the config file at './config.yml'.
Training NLU model...
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/rasa/utils/train_utils.py", line 142, in load_tf_hub_model
return tfhub.load(model_url)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/module_v2.py", line 97, in load
module_path = resolve(handle)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/module_v2.py", line 53, in resolve
return registry.resolver(handle)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/registry.py", line 42, in __call__
return impl(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/compressed_module_resolver.py", line 88, in __call__
self._lock_file_timeout_sec())
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/resolver.py", line 415, in atomic_download
download_fn(handle, tmp_dir)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/compressed_module_resolver.py", line 83, in download
response = self._call_urlopen(request)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/compressed_module_resolver.py", line 96, in _call_urlopen
return url.urlopen(request)
File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/local/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/rasa", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/rasa/__main__.py", line 113, in main
cmdline_arguments.func(cmdline_arguments)
File "/usr/local/lib/python3.6/site-packages/rasa/cli/scaffold.py", line 218, in run
init_project(args, path)
File "/usr/local/lib/python3.6/site-packages/rasa/cli/scaffold.py", line 128, in init_project
print_train_or_instructions(args, path)
File "/usr/local/lib/python3.6/site-packages/rasa/cli/scaffold.py", line 68, in print_train_or_instructions
args.model = rasa.train(domain, config, training_files, output)
File "/usr/local/lib/python3.6/site-packages/rasa/train.py", line 55, in train
loop,
File "/usr/local/lib/python3.6/site-packages/rasa/utils/common.py", line 300, in run_in_loop
result = loop.run_until_complete(f)
File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
File "/usr/local/lib/python3.6/site-packages/rasa/train.py", line 110, in train_async
nlu_additional_arguments=nlu_additional_arguments,
File "/usr/local/lib/python3.6/site-packages/rasa/train.py", line 207, in _train_async_internal
old_model_zip_path=old_model,
File "/usr/local/lib/python3.6/site-packages/rasa/train.py", line 246, in _do_training
additional_arguments=nlu_additional_arguments,
File "/usr/local/lib/python3.6/site-packages/rasa/train.py", line 543, in _train_nlu_with_validated_data
**additional_arguments,
File "/usr/local/lib/python3.6/site-packages/rasa/nlu/train.py", line 97, in train
trainer = Trainer(nlu_config, component_builder)
File "/usr/local/lib/python3.6/site-packages/rasa/nlu/model.py", line 159, in __init__
self.pipeline = self._build_pipeline(cfg, component_builder)
File "/usr/local/lib/python3.6/site-packages/rasa/nlu/model.py", line 171, in _build_pipeline
component = component_builder.create_component(component_cfg, cfg)
File "/usr/local/lib/python3.6/site-packages/rasa/nlu/components.py", line 760, in create_component
component = registry.create_component_by_config(component_config, cfg)
File "/usr/local/lib/python3.6/site-packages/rasa/nlu/registry.py", line 163, in create_component_by_config
return component_class.create(component_config, config)
File "/usr/local/lib/python3.6/site-packages/rasa/nlu/components.py", line 464, in create
return cls(component_config)
File "/usr/local/lib/python3.6/site-packages/rasa/nlu/tokenizers/convert_tokenizer.py", line 44, in __init__
self.module = train_utils.load_tf_hub_model(self.model_url)
File "/usr/local/lib/python3.6/site-packages/rasa/utils/train_utils.py", line 146, in load_tf_hub_model
return tfhub.load(model_url)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/module_v2.py", line 97, in load
module_path = resolve(handle)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/module_v2.py", line 53, in resolve
return registry.resolver(handle)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/registry.py", line 42, in __call__
return impl(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/compressed_module_resolver.py", line 88, in __call__
self._lock_file_timeout_sec())
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/resolver.py", line 415, in atomic_download
download_fn(handle, tmp_dir)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/compressed_module_resolver.py", line 83, in download
response = self._call_urlopen(request)
File "/usr/local/lib/python3.6/site-packages/tensorflow_hub/compressed_module_resolver.py", line 96, in _call_urlopen
return url.urlopen(request)
File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/local/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
ERROR: Service 'rasa' failed to build: The command '/bin/sh -c rasa init --no-prompt' returned a non-zero code: 1

# Fixed code
def cache_key(
    cls, component_meta: Dict[Text, Any], model_metadata: Metadata
) -> Optional[Text]:
    """Cache the component for future use.

    Args:
        component_meta: configuration for the component.
        model_metadata: configuration for the whole pipeline.

    Returns: key of the cache for future retrievals.
    """
    _config = common.update_existing_keys(cls.defaults, component_meta)
    return f"{cls.name}-{get_dict_hash(_config)}"