diff --git a/openpype/modules/default_modules/shotgrid/plugins/publish/integrate_shotgrid_publish.py b/openpype/modules/default_modules/shotgrid/plugins/publish/integrate_shotgrid_publish.py index 8d658ff8aa7..5443f3c2f63 100644 --- a/openpype/modules/default_modules/shotgrid/plugins/publish/integrate_shotgrid_publish.py +++ b/openpype/modules/default_modules/shotgrid/plugins/publish/integrate_shotgrid_publish.py @@ -2,7 +2,11 @@ import pyblish.api class IntegrateShotgridPublish(pyblish.api.InstancePlugin): - """ Commit components to server. """ + """ + Create published Files from representations and add it to version. If + representation is tagged add shotgrid review, it will add it in + path to movie for a movie file or path to frame for an image sequence. + """ order = pyblish.api.IntegratorOrder+0.499 label = "Shotgrid Published Files" @@ -18,9 +22,42 @@ def process(self, instance): for representation in instance.data.get("representations", []): local_path = representation.get("published_path") - code = os.path.basename(local_path) + if "thumbnail" in representation.get("tags", []): + continue + + if "shotgridreview" in representation.get("tags", []): + self.log.info( + "Upload review: {} for version shotgrid {}".format( + local_path, shotgrid_version.get("id")) + ) + self.sg.upload( + "Version", + shotgrid_version.get("id"), + local_path, + field_name="sg_uploaded_movie" + ) + + data_path_to = {} + if representation["ext"] in ["mov", "avi"]: + data_path_to["sg_path_to_movie"] = local_path + elif representation["ext"] in ["jpg", "png", "exr", "tga"]: + data_path_to["sg_path_to_frames"] = local_path + + self.sg.update( + "Version", + shotgrid_version.get("id"), + data_path_to + ) + continue + + published_file = self._find_existing_publish( + code, + context, + shotgrid_version + ) + published_file_data = { "project": context.data.get("shotgridProject"), "code": code, @@ -29,13 +66,6 @@ def process(self, instance): "version": shotgrid_version, "path": {"local_path": local_path} } - - published_file = self._find_existing_publish( - code, - context, - shotgrid_version - ) - if not published_file: published_file = self._create_published(published_file_data) self.log.info( @@ -51,18 +81,6 @@ def process(self, instance): "Update Shotgrid PublishedFile: {}".format(published_file) ) - if "shotgridreview" in representation.get("tags", []): - self.log.info( - "Upload review: {} for version shotgrid {}".format( - local_path, shotgrid_version.get("id")) - ) - self.sg.upload( - "Version", - shotgrid_version.get("id"), - local_path, - field_name="sg_uploaded_movie" - ) - if instance.data["family"] == 'image': self.sg.upload_thumbnail( published_file["type"], diff --git a/openpype/modules/default_modules/shotgrid/plugins/publish/integrate_shotgrid_version.py b/openpype/modules/default_modules/shotgrid/plugins/publish/integrate_shotgrid_version.py index 337ecbdfbca..2bd84a7c06c 100644 --- a/openpype/modules/default_modules/shotgrid/plugins/publish/integrate_shotgrid_version.py +++ b/openpype/modules/default_modules/shotgrid/plugins/publish/integrate_shotgrid_version.py @@ -34,7 +34,14 @@ def process(self, instance): self.log.info("Create Shotgrid version: {}".format(version)) else: self.log.info("Use existing Shotgrid version: {}".format(version)) - self.sg.update("Version", version['id'], _additional_version_data(context)) + + data_to_update = {} + status = context.data.get("intent", {}).get("value") + if status: + data_to_update["sg_status_list"] = status + + self.log.info("Update Shotgrid version with {}".format(data_to_update)) + self.sg.update("Version", version['id'], data_to_update) instance.data["shotgridVersion"] = version @@ -57,16 +64,4 @@ def _create_version(self, code, context): "code": code, } - version_data.update(_additional_version_data(context)) - return self.sg.create("Version", version_data) - - -def _additional_version_data(context): - data = {} - - status = context.data.get("intent", {}).get("value") - if status: - data["sg_status_list"] = status - - return data