Skip to content

Commit

Permalink
Merge pull request #125 from ynput/bugfix/AY-7453_Deadline-product-en…
Browse files Browse the repository at this point in the history
…ding-with-_1-confuses-expected-files-validator

Fix: product ending with  _1 confuses expected files validator
  • Loading branch information
kalisp authored Feb 12, 2025
2 parents 23bc26a + 42695b8 commit 8228974
Showing 1 changed file with 35 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import clique

from ayon_core.pipeline import PublishValidationError
from ayon_core.lib.transcoding import IMAGE_EXTENSIONS


class ValidateExpectedFiles(pyblish.api.InstancePlugin):
Expand Down Expand Up @@ -41,34 +42,10 @@ def process(self, instance):
staging_dir = repre["stagingDir"]
existing_files = self._get_existing_files(staging_dir)

if self.allow_user_override:
# We always check for user override because the user might have
# also overridden the Job frame list to be longer than the
# originally submitted frame range
# todo: We should first check if Job frame range was overridden
# at all so we don't unnecessarily override anything
collection_or_filename = self._get_collection(expected_files)
job_expected_files = self._get_job_expected_files(
collection_or_filename, frame_list)

job_files_diff = job_expected_files.difference(expected_files)
if job_files_diff:
self.log.debug(
"Detected difference in expected output files from "
"Deadline job. Assuming an updated frame list by the "
"user. Difference: {}".format(sorted(job_files_diff))
)

# Update the representation expected files
self.log.info("Update range from actual job range "
"to frame list: {}".format(frame_list))
# single item files must be string not list
repre["files"] = (sorted(job_expected_files)
if len(job_expected_files) > 1 else
list(job_expected_files)[0])

# Update the expected files
expected_files = job_expected_files
is_image = f'.{repre["ext"]}' in IMAGE_EXTENSIONS
if self.allow_user_override and is_image:
expected_files = self._recalculate_expected_files(
expected_files, frame_list, repre)

# We don't use set.difference because we do allow other existing
# files to be in the folder that we might not want to use.
Expand All @@ -84,6 +61,36 @@ def process(self, instance):
)
)

def _recalculate_expected_files(self, expected_files, frame_list, repre):
# We always check for user override because the user might have
# also overridden the Job frame list to be longer than the
# originally submitted frame range
# todo: We should first check if Job frame range was overridden
# at all so we don't unnecessarily override anything
collection_or_filename = self._get_collection(expected_files)
job_expected_files = self._get_job_expected_files(
collection_or_filename, frame_list)

job_files_diff = job_expected_files.difference(expected_files)
if job_files_diff:
self.log.debug(
"Detected difference in expected output files from "
"Deadline job. Assuming an updated frame list by the "
"user. Difference: {}".format(sorted(job_files_diff))
)

# Update the representation expected files
self.log.info("Update range from actual job range "
"to frame list: {}".format(frame_list))
# single item files must be string not list
repre["files"] = (sorted(job_expected_files)
if len(job_expected_files) > 1 else
list(job_expected_files)[0])

# Update the expected files
expected_files = job_expected_files
return expected_files

def _get_dependent_job_ids(self, instance):
"""Returns list of dependent job ids from instance metadata.json
Expand Down

0 comments on commit 8228974

Please sign in to comment.