Simple hack to handle main workflow problem
authorvijeth-aradhya <vijthaaa@gmail.com>
Fri, 16 Jun 2017 19:23:39 +0000 (00:53 +0530)
committervijeth-aradhya <vijthaaa@gmail.com>
Fri, 16 Jun 2017 19:23:39 +0000 (00:53 +0530)
Remove redundunt workflow methods from the other media type's
processing.py.

Fixes #1

mediagoblin/media_types/ascii/processing.py
mediagoblin/media_types/audio/processing.py
mediagoblin/media_types/image/processing.py
mediagoblin/media_types/pdf/processing.py
mediagoblin/media_types/raw_image/processing.py
mediagoblin/media_types/stl/processing.py
mediagoblin/media_types/video/processing.py
mediagoblin/processing/__init__.py
mediagoblin/submit/lib.py

index c9b47fb5d620f788b44b2f723763456edb48fd01..00d04e63e657beb7abb92d630b9cefa7c2fd637d 100644 (file)
@@ -273,8 +273,3 @@ class AsciiProcessingManager(ProcessingManager):
         super(AsciiProcessingManager, self).__init__()
         self.add_processor(InitialProcessor)
         self.add_processor(Resizer)
-
-    def workflow(self, entry_id, feed_url, reprocess_action, reprocess_info=None):
-        ProcessMedia().apply_async(
-            [entry.id, feed_url, reprocess_action, reprocess_info], {},
-            task_id=entry.queued_task_id)
index 15d0b0a7773c55083effda2c67be8ae4eb9ac39f..427309de5f212cdf9d34789c68b0ea6db4e01363 100644 (file)
@@ -365,8 +365,3 @@ class AudioProcessingManager(ProcessingManager):
         self.add_processor(InitialProcessor)
         self.add_processor(Resizer)
         self.add_processor(Transcoder)
-
-    def workflow(self, entry_id, feed_url, reprocess_action, reprocess_info=None):
-        ProcessMedia().apply_async(
-            [entry.id, feed_url, reprocess_action, reprocess_info], {},
-            task_id=entry.queued_task_id)
index 7224a8fdc7e87df9db59beff7375c386bcb6ec1d..7ddf3f35640d55fff43a3fb87ad196f7159d9e7c 100644 (file)
@@ -431,11 +431,6 @@ class ImageProcessingManager(ProcessingManager):
         self.add_processor(Resizer)
         self.add_processor(MetadataProcessing)
 
-    def workflow(self, entry_id, feed_url, reprocess_action, reprocess_info=None):
-        ProcessMedia().apply_async(
-            [entry.id, feed_url, reprocess_action, reprocess_info], {},
-            task_id=entry.queued_task_id)
-
 
 if __name__ == '__main__':
     import sys
index e6e6e0a9b8e8a5033f02ace5abf9cf070d7e011a..ac4bab6d55a51a39594d9fabd9d6a472c9ccc8ff 100644 (file)
@@ -470,8 +470,3 @@ class PdfProcessingManager(ProcessingManager):
         super(PdfProcessingManager, self).__init__()
         self.add_processor(InitialProcessor)
         self.add_processor(Resizer)
-
-    def workflow(self, entry_id, feed_url, reprocess_action, reprocess_info=None):
-        ProcessMedia().apply_async(
-            [entry.id, feed_url, reprocess_action, reprocess_info], {},
-            task_id=entry.queued_task_id)
index 4bfd9f3a87b10030bbe6c5f28e0da90551af5b67..740ba2ddaa25b97c52f66231b4f84a1da61cb178 100644 (file)
@@ -80,8 +80,3 @@ class RawImageProcessingManager(ProcessingManager):
         super(RawImageProcessingManager, self).__init__()
         self.add_processor(InitialRawProcessor)
         self.add_processor(Resizer)
-
-    def workflow(self, entry_id, feed_url, reprocess_action, reprocess_info=None):
-        ProcessMedia().apply_async(
-            [entry.id, feed_url, reprocess_action, reprocess_info], {},
-            task_id=entry.queued_task_id)
index cd3ffd8c84852a9f50bb679953e879a9e50b4f07..55764aeb2454047af51b56d0c969f70b6ff270a2 100644 (file)
@@ -368,8 +368,3 @@ class StlProcessingManager(ProcessingManager):
         super(StlProcessingManager, self).__init__()
         self.add_processor(InitialProcessor)
         self.add_processor(Resizer)
-
-    def workflow(self, entry_id, feed_url, reprocess_action, reprocess_info=None):
-        ProcessMedia().apply_async(
-            [entry.id, feed_url, reprocess_action, reprocess_info], {},
-            task_id=entry.queued_task_id)
index 586a0c85e9ab536972a3aa16eb464bd693ea94d5..e881636c214561be2a1358ed1b73db6a8cd51c0c 100644 (file)
@@ -30,7 +30,6 @@ from mediagoblin.processing import (
     ProcessingManager, request_from_args,
     get_process_filename, store_public,
     copy_original, get_entry_and_processing_manager)
-from mediagoblin.processing.task import ProcessMedia
 from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
 from mediagoblin.media_types import MissingComponents
 
@@ -543,7 +542,7 @@ class VideoProcessingManager(ProcessingManager):
         self.add_processor(Resizer)
         self.add_processor(Transcoder)
 
-    def workflow(self, entry_id, feed_url, reprocess_action, reprocess_info=None):
+    def workflow(self, entry, feed_url, reprocess_action, reprocess_info=None):
 
         reprocess_info = reprocess_info or {}
         if 'vp8_quality' not in reprocess_info:
@@ -556,25 +555,21 @@ class VideoProcessingManager(ProcessingManager):
             reprocess_info['thumb_size'] = None
 
         transcoding_tasks = group([
-            main_task.signature(args=(entry_id, '480p', ACCEPTED_RESOLUTIONS['480p']),
+            main_task.signature(args=(entry.id, '480p', ACCEPTED_RESOLUTIONS['480p']),
                                 kwargs=reprocess_info, queue='default',
                                 priority=5, immutable=True),
-            complimentary_task.signature(args=(entry_id, '360p', ACCEPTED_RESOLUTIONS['360p']),
+            complimentary_task.signature(args=(entry.id, '360p', ACCEPTED_RESOLUTIONS['360p']),
                                          kwargs=reprocess_info, queue='default',
                                          priority=4, immutable=True),
-            complimentary_task.signature(args=(entry_id, '720p', ACCEPTED_RESOLUTIONS['720p']),
+            complimentary_task.signature(args=(entry.id, '720p', ACCEPTED_RESOLUTIONS['720p']),
                                          kwargs=reprocess_info, queue='default',
                                          priority=3, immutable=True),
         ])
 
-        cleanup_task = processing_cleanup.signature(args=(entry_id,),
+        cleanup_task = processing_cleanup.signature(args=(entry.id,),
                                                     queue='default', immutable=True)
 
-        """
-        main_task.apply_async(args=(entry_id, '480p', ACCEPTED_RESOLUTIONS['480p']),
-                              kwargs=reprocess_info, queue='default',
-                              priority=5, immutable=True)
-        processing_cleanup.apply_async(args=(entry_id,), queue='default', immutable=True)
-        """
-
         chord(transcoding_tasks)(cleanup_task)
+
+        # Not sure what to return since we are scheduling the task here itself
+        return 1
index 98031bbcaba183bd91049915f7af50f4a14f5b35..7d407a36700d5032d57a73d7ef533bce6b49d618 100644 (file)
@@ -257,12 +257,11 @@ class ProcessingManager(object):
 
         return processor
 
-    def workflow(self, entry_id, feed_url, reprocess_action, reprocess_info=None):
+    def workflow(self, entry, feed_url, reprocess_action, reprocess_info=None):
         """
         Returns the Celery command needed to proceed with media processing
-        *This method has to be implemented in all media types*
         """
-        raise NotImplementedError
+        return None
 
 
 def request_from_args(args, which_args):
index a6d564f13fce2023c256322183a02b8592a87969..b228dbd14012b5aaa67b4d409988ed48591f3b5e 100644 (file)
@@ -266,7 +266,11 @@ def run_process_media(entry, feed_url=None,
     entry, manager = get_entry_and_processing_manager(entry.id)
 
     try:
-        manager.workflow(entry.id, feed_url, reprocess_action, reprocess_info)
+        wf = manager.workflow(entry, feed_url, reprocess_action, reprocess_info)
+        if wf is None:
+            ProcessMedia().apply_async(
+                [entry.id, feed_url, reprocess_action, reprocess_info], {},
+                task_id=entry.queued_task_id)
     except BaseException as exc:
         # The purpose of this section is because when running in "lazy"
         # or always-eager-with-exceptions-propagated celery mode that