Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering for specific frames for simple files representations #958

Merged
merged 25 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2f6ca5a
Implemented explicit frames for simple files representations
kalisp Oct 18, 2024
78bc9c9
Merge remote-tracking branch 'origin/enhancement/get-instances-task-t…
kalisp Oct 30, 2024
632035c
Merge branch 'develop' of https://github.com/ynput/ayon-core into fea…
kalisp Oct 30, 2024
3f2d6f0
Merge branch 'develop' of https://github.com/ynput/ayon-core into fea…
kalisp Oct 30, 2024
2f170dc
Merge remote-tracking branch 'origin/enhancement/get-instances-task-t…
kalisp Oct 30, 2024
e8a3ba6
Merge branch 'develop' into feature/AY-6789_Render-instance-support-o…
BigRoy Nov 4, 2024
8a074da
Fix single frame render
kalisp Nov 4, 2024
4a5583c
Merge branch 'develop' of https://github.com/ynput/ayon-core into fea…
kalisp Nov 6, 2024
87bb613
Added optionality to new argument in method signature
kalisp Nov 7, 2024
4585cdb
Merge branch 'develop' into feature/AY-6789_Render-instance-support-o…
MustafaJafar Nov 12, 2024
bdd2615
Merge branch 'develop' of https://github.com/ynput/ayon-core into fea…
kalisp Nov 19, 2024
6ba4206
Merge remote-tracking branch 'origin/feature/AY-6789_Render-instance-…
kalisp Nov 19, 2024
f656113
Merge branch 'develop' of https://github.com/ynput/ayon-core into fea…
kalisp Nov 21, 2024
c56cd07
Provided backward compatibility for prepare_representations
kalisp Nov 21, 2024
c271687
Do not convert to str unnecessary
kalisp Nov 21, 2024
de88260
frames_to_render are now list of integers
kalisp Nov 21, 2024
630d2d4
frames_to_render are now list of integers
kalisp Nov 21, 2024
5f31752
Used comprehension
kalisp Nov 21, 2024
fd20885
Used comprehension
kalisp Nov 21, 2024
80ab628
Changed condition to bail early
kalisp Nov 21, 2024
b6945c1
Merge
kalisp Nov 21, 2024
63592f9
Used comprehension
kalisp Nov 21, 2024
112c4bd
Used comprehension
kalisp Nov 21, 2024
897d79a
Merge branch 'develop' into feature/AY-6789_Render-instance-support-o…
kalisp Nov 21, 2024
5da458d
Merge branch 'develop' into feature/AY-6789_Render-instance-support-o…
kalisp Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 79 additions & 10 deletions client/ayon_core/pipeline/farm/pyblish_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import attr
import ayon_api
import clique
from ayon_core.lib import Logger
from ayon_core.lib import Logger, collect_frames
from ayon_core.pipeline import get_current_project_name, get_representation_path
from ayon_core.pipeline.create import get_product_name
from ayon_core.pipeline.farm.patterning import match_aov_pattern
Expand Down Expand Up @@ -295,11 +295,17 @@ def _add_review_families(families):
return families


def prepare_representations(skeleton_data, exp_files, anatomy, aov_filter,
skip_integration_repre_list,
do_not_add_review,
context,
color_managed_plugin):
def prepare_representations(
skeleton_data,
exp_files,
anatomy,
aov_filter,
skip_integration_repre_list,
do_not_add_review,
context,
color_managed_plugin,
frames_to_render=None
):
"""Create representations for file sequences.

This will return representations of expected files if they are not
Expand All @@ -315,6 +321,8 @@ def prepare_representations(skeleton_data, exp_files, anatomy, aov_filter,
skip_integration_repre_list (list): exclude specific extensions,
do_not_add_review (bool): explicitly skip review
color_managed_plugin (publish.ColormanagedPyblishPluginMixin)
frames_to_render (str): implicit or explicit range of frames to render
this value is sent to Deadline in JobInfo.Frames
Returns:
list of representations

Expand All @@ -325,6 +333,14 @@ def prepare_representations(skeleton_data, exp_files, anatomy, aov_filter,

log = Logger.get_logger("farm_publishing")

if frames_to_render is not None:
frames_to_render = _get_real_frames_to_render(frames_to_render)
else:
# Backwards compatibility for older logic
frame_start = int(skeleton_data.get("frameStartHandle"))
frame_end = int(skeleton_data.get("frameEndHandle"))
frames_to_render = list(range(frame_start, frame_end + 1))

# create representation for every collected sequence
for collection in collections:
ext = collection.tail.lstrip(".")
Expand Down Expand Up @@ -361,18 +377,21 @@ def prepare_representations(skeleton_data, exp_files, anatomy, aov_filter,
" This may cause issues on farm."
).format(staging))

frame_start = int(skeleton_data.get("frameStartHandle"))
frame_start = frames_to_render[0]
frame_end = frames_to_render[-1]
if skeleton_data.get("slate"):
frame_start -= 1

files = _get_real_files_to_rendered(collection, frames_to_render)

# explicitly disable review by user
preview = preview and not do_not_add_review
rep = {
"name": ext,
"ext": ext,
"files": [os.path.basename(f) for f in list(collection)],
"files": files,
"frameStart": frame_start,
"frameEnd": int(skeleton_data.get("frameEndHandle")),
"frameEnd": frame_end,
# If expectedFile are absolute, we need only filenames
"stagingDir": staging,
"fps": skeleton_data.get("fps"),
Expand Down Expand Up @@ -413,10 +432,13 @@ def prepare_representations(skeleton_data, exp_files, anatomy, aov_filter,
" This may cause issues on farm."
).format(staging))

files = _get_real_files_to_rendered(
[os.path.basename(remainder)], frames_to_render)

rep = {
"name": ext,
"ext": ext,
"files": os.path.basename(remainder),
"files": files[0],
"stagingDir": staging,
}

Expand Down Expand Up @@ -453,6 +475,53 @@ def prepare_representations(skeleton_data, exp_files, anatomy, aov_filter,
return representations


def _get_real_frames_to_render(frames):
"""Returns list of frames that should be rendered.

Artists could want to selectively render only particular frames
"""
frames_to_render = []
for frame in frames.split(","):
if "-" in frame:
splitted = frame.split("-")
frames_to_render.extend(
range(int(splitted[0]), int(splitted[1])+1))
else:
frames_to_render.append(int(frame))
frames_to_render.sort()
return frames_to_render


def _get_real_files_to_rendered(collection, frames_to_render):
"""Use expected files based on real frames_to_render.

Artists might explicitly set frames they want to render via Publisher UI.
This uses this value to filter out files
Args:
frames_to_render (list): of str '1001'
"""
files = [os.path.basename(f) for f in list(collection)]
file_name, extracted_frame = list(collect_frames(files).items())[0]

if not extracted_frame:
return files

found_frame_pattern_length = len(extracted_frame)
normalized_frames_to_render = {
str(frame_to_render).zfill(found_frame_pattern_length)
for frame_to_render in frames_to_render
}

return [
file_name
for file_name in files
if any(
frame in file_name
for frame in normalized_frames_to_render
)
]


def create_instances_for_aov(instance, skeleton, aov_filter,
skip_integration_repre_list,
do_not_add_review):
Expand Down