Caching TF-Hub modules

Setting TFHUB_CACHE_DIR did update the path, but it didn’t stop the model from being downloaded again during the docker runtime. But what I did observe was that there was a new folder with a few files created in the docker container. I copied these over to my host and built the new docker image with these files and lo and behold, it worked like a charm!

Docker logs:

2020-02-03 02:29:00 INFO     absl  - Using models/tfhub to cache modules.
2020-02-03 02:29:04 DEBUG    rasa.core.tracker_store  - Connected to InMemoryTrackerStore.
2020-02-03 02:29:04 DEBUG    rasa.core.lock_store  - Connected to lock store 'InMemoryLockStore'.
2020-02-03 02:29:05 DEBUG    rasa.model  - Extracted model to '/tmp/tmp1wvz5fcv'.
2020-02-03 02:29:05 DEBUG    pykwalify.compat  - Using yaml library: /usr/local/lib/python3.7/site-packages/ruamel/yaml/__init__.py
2020-02-03 02:29:06 DEBUG    rasa.core.nlg.generator  - Instantiated NLG to 'TemplatedNaturalLanguageGenerator'.

Details of the files:

models
└──tfhub
   │ model.tar.gz
   │ 61ee56c901ee8aa67fa63e1152683dfe55693b04.descriptor.txt
   │
   └─61ee56c901ee8aa67fa63e1152683dfe55693b04
      │ assets
      │ saved_model.pb
      │ tfhub_module.pb
      │ variables
	     │ variables.data-00000-of-00002
	     │ variables.data-00001-of-00002
	     │ variables.index

I found a post on medium to do this via code How to run TF hub locally without internet connection