Skip to content

Commit c1e4c6a

Browse files
committed
Fixing the model hash changing when restarting the docker container
1 parent eb4971f commit c1e4c6a

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ To run the API, go the to the API's directory and run the following:
6666
#### Using Linux based docker:
6767

6868
```sh
69-
sudo NV_GPU=0 nvidia-docker run -itv $(pwd)/models:/models -p <docker_host_port>:4343 tensorflow_inference_api_gpu
69+
sudo NV_GPU=0 nvidia-docker run -itv $(pwd)/models:/models -v $(pwd)/models_hash:/models_hash -p <docker_host_port>:4343 tensorflow_inference_api_gpu
7070
```
7171

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

models_hash/model_hash.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

src/main/deep_learning_service.py

+3-3
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

-1
This file was deleted.

0 commit comments

Comments
 (0)