Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/unreal_from_published
Browse files Browse the repository at this point in the history
  • Loading branch information
kalisp authored Feb 13, 2025
2 parents 64a368d + f9556b3 commit 8c0595d
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class CollectDeadlineJobEnvVars(pyblish.api.ContextPlugin):

# Not sure how this is usefull for farm, scared to remove
"PYBLISHPLUGINPATH",

# NOTE still required by GlobalPreLoadJob.py, but might not be set by
# ayon-core anymore
"AYON_DEFAULT_SETTINGS_VARIANT",
]

def process(self, context):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def _submit_deadline_post_job(
"--targets", "deadline",
"--targets", "farm",
]
# TODO remove when AYON launcher respects environment variable
# 'AYON_DEFAULT_SETTINGS_VARIANT'
# TODO remove settings variant handling when not needed anymore
# which should be when package.py defines 'core>1.1.1' .
settings_variant = os.environ["AYON_DEFAULT_SETTINGS_VARIANT"]
if settings_variant == "staging":
args.append("--use-staging")
Expand Down
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
18 changes: 12 additions & 6 deletions client/ayon_deadline/repository/custom/plugins/GlobalJobPreLoad.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
FileUtils,
DirectoryUtils,
)
__version__ = "1.2.0"
__version__ = "1.2.1"
VERSION_REGEX = re.compile(
r"(?P<major>0|[1-9]\d*)"
r"\.(?P<minor>0|[1-9]\d*)"
Expand Down Expand Up @@ -558,8 +558,12 @@ def inject_ayon_environment(deadlinePlugin):
]

# staging requires passing argument
# TODO could be switched to env var after https://github.com/ynput/ayon-launcher/issues/123
settings_variant = job.GetJobEnvironmentKeyValue("AYON_DEFAULT_SETTINGS_VARIANT") # noqa
# TODO could be removed when PR in ayon-core starts to fill
# 'AYON_USE_STAGING' (https://github.com/ynput/ayon-core/pull/1130)
# - add requirement for "core>=1.1.1" to 'package.py' when removed
settings_variant = job.GetJobEnvironmentKeyValue(
"AYON_DEFAULT_SETTINGS_VARIANT"
)
if settings_variant == "staging":
args.append("--use-staging")

Expand All @@ -583,9 +587,11 @@ def inject_ayon_environment(deadlinePlugin):
"AYON_BUNDLE_NAME": ayon_bundle_name,
}

automatic_tests = job.GetJobEnvironmentKeyValue("AYON_IN_TESTS")
if automatic_tests:
environment["AYON_IN_TESTS"] = automatic_tests
for key in ("AYON_USE_STAGING", "AYON_IN_TESTS"):
value = job.GetJobEnvironmentKeyValue(key)
if value:
environment[key] = value

for env, val in environment.items():
# Add the env var for the Render Plugin that is about to render
deadlinePlugin.SetEnvironmentVariable(env, val)
Expand Down

0 comments on commit 8c0595d

Please sign in to comment.