diff --git a/openpype/hosts/webpublisher/webserver_service/webpublish_routes.py b/openpype/hosts/webpublisher/webserver_service/webpublish_routes.py index 73e5113f38a..e34a899c4bb 100644 --- a/openpype/hosts/webpublisher/webserver_service/webpublish_routes.py +++ b/openpype/hosts/webpublisher/webserver_service/webpublish_routes.py @@ -20,11 +20,16 @@ class RestApiResource: """Resource carrying needed info and Avalon DB connection for publish.""" - def __init__(self, server_manager, executable, upload_dir): + def __init__(self, server_manager, executable, upload_dir, + studio_task_queue=None): self.server_manager = server_manager self.upload_dir = upload_dir self.executable = executable + if studio_task_queue is None: + studio_task_queue = collections.deque().dequeu + self.studio_task_queue = studio_task_queue + self.dbcon = AvalonMongoDB() self.dbcon.install() @@ -182,8 +187,6 @@ async def post(self, request) -> Response: msg = "Non existent OpenPype executable {}".format(openpype_app) raise RuntimeError(msg) - # for postprocessing in host, currently only PS - output = {} log.info("WebpublisherBatchPublishEndpoint called") content = await request.json() @@ -203,7 +206,10 @@ async def post(self, request) -> Response: # would change # - targets argument is not used in 'remotepublishfromapp' "targets": None - } + }, + # does publish need to be handled by a queue, eg. only + # single process running concurrently? + "add_to_queue": True } ] @@ -219,19 +225,20 @@ async def post(self, request) -> Response: "targets": ["filespublish"] } + add_to_queue = False if content.get("studio_processing"): log.info("Post processing called") batch_data = parse_json(os.path.join(batch_path, "manifest.json")) if not batch_data: raise ValueError( - "Cannot parse batch meta in {} folder".format(batch_path)) + "Cannot parse batch manifest in {}".format(batch_path)) task_dir_name = batch_data["tasks"][0] task_data = parse_json(os.path.join(batch_path, task_dir_name, "manifest.json")) if not task_data: raise ValueError( - "Cannot parse batch meta in {} folder".format(task_data)) + "Cannot parse task manifest in {}".format(task_data)) for process_filter in studio_processing_filters: filter_extensions = process_filter.get("extensions") or [] @@ -244,6 +251,7 @@ async def post(self, request) -> Response: add_args.update( process_filter.get("arguments") or {} ) + add_to_queue = process_filter["add_to_queue"] break args = [ @@ -263,11 +271,14 @@ async def post(self, request) -> Response: args.append(value) log.info("args:: {}".format(args)) + if add_to_queue: + log.debug("Adding to queue") + self.resource.studio_task_queue.append(args) + else: + subprocess.call(args) - subprocess.call(args) return Response( status=200, - body=self.resource.encode(output), content_type="application/json" ) diff --git a/openpype/hosts/webpublisher/webserver_service/webserver_cli.py b/openpype/hosts/webpublisher/webserver_service/webserver_cli.py index d00d269059f..b7841054612 100644 --- a/openpype/hosts/webpublisher/webserver_service/webserver_cli.py +++ b/openpype/hosts/webpublisher/webserver_service/webserver_cli.py @@ -1,8 +1,10 @@ +import collections import time import os from datetime import datetime import requests import json +import subprocess from openpype.lib import PypeLogger @@ -31,10 +33,13 @@ def run_webserver(*args, **kwargs): port = kwargs.get("port") or 8079 server_manager = webserver_module.create_new_server_manager(port, host) webserver_url = server_manager.url + # queue for remotepublishfromapp tasks + studio_task_queue = collections.deque() resource = RestApiResource(server_manager, upload_dir=kwargs["upload_dir"], - executable=kwargs["executable"]) + executable=kwargs["executable"], + studio_task_queue=studio_task_queue) projects_endpoint = WebpublisherProjectsEndpoint(resource) server_manager.add_route( "GET", @@ -88,6 +93,10 @@ def run_webserver(*args, **kwargs): if time.time() - last_reprocessed > 20: reprocess_failed(kwargs["upload_dir"], webserver_url) last_reprocessed = time.time() + if studio_task_queue: + args = studio_task_queue.popleft() + subprocess.call(args) # blocking call + time.sleep(1.0) diff --git a/openpype/settings/defaults/project_settings/photoshop.json b/openpype/settings/defaults/project_settings/photoshop.json index eb9f96e3480..0c24c943ec4 100644 --- a/openpype/settings/defaults/project_settings/photoshop.json +++ b/openpype/settings/defaults/project_settings/photoshop.json @@ -30,8 +30,7 @@ }, "ExtractReview": { "jpg_options": { - "tags": [ - ] + "tags": [] }, "mov_options": { "tags": [