From 9ab29f27f775cacee1924254c19671c77713ab79 Mon Sep 17 00:00:00 2001 From: Matthew Greenberg Date: Fri, 14 Jun 2019 14:58:54 -0700 Subject: [PATCH 1/4] bug fixes --- multivitamin/applications/images/frame_extractor.py | 2 -- multivitamin/media/pims_media_retriever.py | 3 --- 2 files changed, 5 deletions(-) diff --git a/multivitamin/applications/images/frame_extractor.py b/multivitamin/applications/images/frame_extractor.py index 0b2cabd..b86d457 100644 --- a/multivitamin/applications/images/frame_extractor.py +++ b/multivitamin/applications/images/frame_extractor.py @@ -249,11 +249,9 @@ def process_properties(self): if self._local_dir is not None: self._add_contents_to_local(contents) - self.response.url_original = self.video_url new_url = self._s3_url_format.format( bucket=self._s3_bucket, s3_key=self.contents_file_key ) - self.response.url = new_url p = Property( server=self.name, ver=self.version, diff --git a/multivitamin/media/pims_media_retriever.py b/multivitamin/media/pims_media_retriever.py index aaf9a4d..9527e1d 100644 --- a/multivitamin/media/pims_media_retriever.py +++ b/multivitamin/media/pims_media_retriever.py @@ -37,16 +37,13 @@ def _create_video_capture(self): return self._cap - @property def _get_fps_from_video_capture(self): return self.video_capture.frame_rate - @property def _get_num_frames(self): """Get the total number of frames.""" return len(self.video_capture) - @property def _get_video_frame_shape(self): """Get height by width by channels for frames.""" shape = self.video_capture.frame_shape From 270783b6c63c8ab621bdc5854d87f3eb85d2f087 Mon Sep 17 00:00:00 2001 From: Matthew Greenberg Date: Fri, 14 Jun 2019 15:02:52 -0700 Subject: [PATCH 2/4] better exception handling --- .../applications/images/frame_extractor.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/multivitamin/applications/images/frame_extractor.py b/multivitamin/applications/images/frame_extractor.py index b86d457..a32eb47 100644 --- a/multivitamin/applications/images/frame_extractor.py +++ b/multivitamin/applications/images/frame_extractor.py @@ -5,9 +5,11 @@ import boto3 import glog as log import numpy as np +import traceback from PIL import Image -from multivitamin.module import PropertiesModule + +from multivitamin.module import PropertiesModule, Codes from multivitamin.utils.work_handler import WorkerManager from multivitamin.media import MediaRetriever from multivitamin.data.response.utils import get_current_time @@ -186,7 +188,15 @@ def process_properties(self): # log.info('Getting hash') # video_hash = hashfileobject(filelike, hexdigest=True) self.video_url = self.response.request.url - self.med_ret = MediaRetriever(self.video_url) + try: + log.info(f"Loading media from url: {self.response.request.url}") + self.media = MediaRetriever(self.video_url) + except Exception as e: + log.error(e) + log.error(traceback.print_exc()) + self.code = Codes.ERROR_LOADING_MEDIA + return self.update_and_return_response() + self.contents_file_key = get_contents_file_s3_key(self.video_url, self._sample_rate) video_id = self.contents_file_key.split("/")[0] From 536599fd0a6fe062a2f56bb9a995d46575ef421b Mon Sep 17 00:00:00 2001 From: Matthew Greenberg Date: Fri, 14 Jun 2019 15:05:58 -0700 Subject: [PATCH 3/4] fixing spelling --- multivitamin/applications/images/frame_extractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multivitamin/applications/images/frame_extractor.py b/multivitamin/applications/images/frame_extractor.py index a32eb47..b3158f6 100644 --- a/multivitamin/applications/images/frame_extractor.py +++ b/multivitamin/applications/images/frame_extractor.py @@ -190,7 +190,7 @@ def process_properties(self): self.video_url = self.response.request.url try: log.info(f"Loading media from url: {self.response.request.url}") - self.media = MediaRetriever(self.video_url) + self.med_ret = MediaRetriever(self.video_url) except Exception as e: log.error(e) log.error(traceback.print_exc()) From f2d47fb6340e0fce4747c1dab19e3b6aca178917 Mon Sep 17 00:00:00 2001 From: Matthew Greenberg Date: Fri, 14 Jun 2019 15:12:27 -0700 Subject: [PATCH 4/4] remove double update --- multivitamin/applications/images/frame_extractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multivitamin/applications/images/frame_extractor.py b/multivitamin/applications/images/frame_extractor.py index b3158f6..49863c8 100644 --- a/multivitamin/applications/images/frame_extractor.py +++ b/multivitamin/applications/images/frame_extractor.py @@ -195,7 +195,7 @@ def process_properties(self): log.error(e) log.error(traceback.print_exc()) self.code = Codes.ERROR_LOADING_MEDIA - return self.update_and_return_response() + return self.contents_file_key = get_contents_file_s3_key(self.video_url, self._sample_rate)