From b140cca9b9ba80414e281674a20f93ccdd94b7fc Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Fri, 30 Aug 2019 13:05:44 +0800 Subject: [PATCH] fix(service): fix exception when no chunks --- gnes/base/__init__.py | 12 ++++++------ gnes/preprocessor/audio/audio_vanilla.py | 2 +- gnes/preprocessor/video/ffmpeg.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gnes/base/__init__.py b/gnes/base/__init__.py index 3578af9a..5d30d0bf 100644 --- a/gnes/base/__init__.py +++ b/gnes/base/__init__.py @@ -227,9 +227,9 @@ def __setstate__(self, d): self.logger = set_logger(self.__class__.__name__, self.verbose) try: self._post_init_wrapper() - except ImportError: - self.logger.info('ImportError is often caused by a missing component, ' - 'which often can be solved by "pip install" relevant package.') + except ImportError as ex: + self.logger.warning('ImportError is often caused by a missing component, ' + 'which often can be solved by "pip install" relevant package. %s' % ex, exc_info=True) def train(self, *args, **kwargs): """ @@ -248,7 +248,7 @@ def dump(self, filename: str = None) -> None: f = tempfile.NamedTemporaryFile('w', delete=False, dir=os.environ.get('GNES_VOLUME', None)).name with open(f, 'wb') as fp: pickle.dump(self, fp) - self.logger.info('model is stored to %s' % f) + self.logger.critical('model is serialized to %s' % f) @profiling def dump_yaml(self, filename: str = None) -> None: @@ -334,7 +334,7 @@ def _get_instance_from_yaml(cls, constructor, node, stop_on_import_error=False): load_from_dump = False if dump_path: obj = cls.load(dump_path) - obj.logger.info('restore %s from %s' % (cls.__name__, dump_path)) + obj.logger.critical('restore %s from %s' % (cls.__name__, dump_path)) load_from_dump = True else: cls.init_from_yaml = True @@ -351,7 +351,7 @@ def _get_instance_from_yaml(cls, constructor, node, stop_on_import_error=False): tmp_p = {kk: _expand_env_var(vv) for kk, vv in data.get('parameters', {}).items()} obj = cls(**tmp_p, gnes_config=data.get('gnes_config', {})) - obj.logger.info('initialize %s from a yaml config' % cls.__name__) + obj.logger.critical('initialize %s from a yaml config' % cls.__name__) cls.init_from_yaml = False if node.tag in {'!PipelineEncoder', '!CompositionalTrainableBase'}: diff --git a/gnes/preprocessor/audio/audio_vanilla.py b/gnes/preprocessor/audio/audio_vanilla.py index e587ce96..9079b360 100644 --- a/gnes/preprocessor/audio/audio_vanilla.py +++ b/gnes/preprocessor/audio/audio_vanilla.py @@ -40,6 +40,6 @@ def apply(self, doc: 'gnes_pb2.Document') -> None: c.offset = ci c.weight = 1 / len(audio) else: - self.logger.info('bad document: no audio extracted') + self.logger.warning('bad document: no audio extracted') else: self.logger.error('bad document: "raw_bytes" is empty!') diff --git a/gnes/preprocessor/video/ffmpeg.py b/gnes/preprocessor/video/ffmpeg.py index d0be4372..b067c411 100644 --- a/gnes/preprocessor/video/ffmpeg.py +++ b/gnes/preprocessor/video/ffmpeg.py @@ -178,7 +178,7 @@ def apply(self, doc: 'gnes_pb2.Document') -> None: c.weight = 1 / len(sub_videos) else: - self.logger.info('bad document: no key frames extracted') + self.logger.warning('bad document: no key frames extracted') else: self.logger.error('bad document: "raw_bytes" is empty!')