Skip to content

Commit ceb196a

Browse files
committed
Fixing the model hash changing when restarting the docker container
1 parent 9153228 commit ceb196a

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ To run the API, go the to the API's directory and run the following:
6161
#### Using Linux based docker:
6262

6363
```sh
64-
sudo docker run -itv $(pwd)/models:/models -p <docker_host_port>:4343 tensorflow_inference_api_cpu
64+
sudo docker run -itv $(pwd)/models:/models -v $(pwd)/models_hash:/models_hash -p <docker_host_port>:4343 tensorflow_inference_api_cpu
6565
```
6666

6767
#### Using Windows based docker:
6868

6969
```sh
70-
docker run -itv ${PWD}/models:/models -p <docker_host_port>:4343 tensorflow_inference_api_cpu
70+
docker run -itv ${PWD}/models:/models -v ${PWD}/models_hash:/models_hash -p <docker_host_port>:4343 tensorflow_inference_api_cpu
7171
```
7272

7373
The <docker_host_port> can be any unique port of your choice.

models_hash/model_hash.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

src/main/deep_learning_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self):
1717
# dictionary to hold the model instances (model_name: string -> model_instance: AbstractInferenceEngine)
1818
self.models_dict = {}
1919
# read from json file and append to dict
20-
file_name = 'model_hash.json'
20+
file_name = '/models_hash/model_hash.json'
2121
file_exists = os.path.exists(file_name)
2222
if file_exists:
2323
try:
@@ -26,7 +26,7 @@ def __init__(self):
2626
except:
2727
self.models_hash_dict = {}
2828
else:
29-
with open('model_hash.json', 'w'):
29+
with open('/models_hash/model_hash.json', 'w'):
3030
self.models_hash_dict = {}
3131
self.labels_hash_dict = {}
3232
self.base_models_dir = '/models'
@@ -62,7 +62,7 @@ def load_all_models(self):
6262
if key not in models:
6363
del self.models_hash_dict[key]
6464
# append to json file
65-
with open('model_hash.json', "w") as fp:
65+
with open('/models_hash/model_hash.json', "w") as fp:
6666
json.dump(self.models_hash_dict, fp)
6767
return self.models_hash_dict
6868

src/main/model_hash.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)