Skip to content

Commit

Permalink
fix: rich tips.
Browse files Browse the repository at this point in the history
  • Loading branch information
kerlomz committed Jan 15, 2019
1 parent 0e13e74 commit be1f6b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 4 additions & 1 deletion config.py
Expand Up @@ -147,6 +147,7 @@ def __init__(self, conf: Config, model_conf: str):
self.model_name_md5 = None
self.color_engine = None
self.cf_model = self.read_conf
self.model_exists = False
self.assignment()
self.graph_name = "{}&{}".format(self.target_model, self.size_string)

Expand Down Expand Up @@ -195,9 +196,11 @@ def assignment(self):
if not os.path.exists(self.compile_model_path):
if not os.path.exists(self.graph_path):
os.makedirs(self.graph_path)
raise Exception(
self.logger.error(
'{} not found, please put the trained model in the graph directory.'.format(self.compile_model_path)
)
else:
self.model_exists = True

def size_match(self, size_str):
return size_str == self.size_string
Expand Down
16 changes: 11 additions & 5 deletions event_handler.py
Expand Up @@ -46,6 +46,10 @@ def init(self):
def _add(self, src_path, is_first=False, count=0):
try:
model_path = str(src_path)
path_exists = os.path.exists(model_path)
if not path_exists and count > 0:
self.logger.error("{} not found, retry attempt is terminated.".format(model_path))
return
if 'model_demo.yaml' in model_path:
self.logger.warning(
"\n-------------------------------------------------------------------\n"
Expand Down Expand Up @@ -98,7 +102,7 @@ def _add(self, src_path, is_first=False, count=0):

except Exception as e:
self.interface_manager.report(src_path)
print(e.args)
self.logger.error(e)

def delete(self, src_path):
try:
Expand All @@ -110,11 +114,11 @@ def delete(self, src_path):
self.name_map.pop(inner_key)
self.logger.info("Unload the model: {} ({})".format(graph_name, inner_key))
except Exception as e:
print(e)
self.logger.error("Config File [{}] does not exist.".format(str(e).replace("'", "")))

def on_created(self, event):
if event.is_directory:
print("directory created:{0}".format(event.src_path))
self.logger.info("directory created:{0}".format(event.src_path))
else:
model_path = str(event.src_path)
self._add(model_path)
Expand All @@ -129,12 +133,14 @@ def on_created(self, event):

def on_deleted(self, event):
if event.is_directory:
print("directory deleted:{0}".format(event.src_path))
self.logger.info("directory deleted:{0}".format(event.src_path))
else:
model_path = str(event.src_path)
if model_path in self.interface_manager.invalid_group:
self.interface_manager.invalid_group.pop(model_path)
self.delete(model_path)
inner_key = PathUtils.get_file_name(model_path)
if inner_key in self.name_map:
self.delete(model_path)
self.logger.info(
"\n - Number of interfaces: {}"
"\n - Current online interface: \n\t - {}"
Expand Down
1 change: 0 additions & 1 deletion predict.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Author: kerlomz <kerlomz@gmail.com>
import numpy as np
from config import ModelConfig


Expand Down

0 comments on commit be1f6b8

Please sign in to comment.