Bases: InstancePlugin
Copies files of last version to fill gaps.
This functionality allows to render and replace only selected frames. It produces new version with newly rendered frames and rest of them is used from last version (if available).
Source code in client/ayon_deadline/plugins/publish/global/extract_last_version_files.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 | class ExtractLastVersionFiles(pyblish.api.InstancePlugin):
"""Copies files of last version to fill gaps.
This functionality allows to render and replace only selected frames.
It produces new version with newly rendered frames and rest of them is used
from last version (if available).
"""
label = "Copy Last Version Files"
order = pyblish.api.ExtractorOrder
families = ["render"]
targets = ["deadline"]
settings_category = "deadline"
def process(self, instance):
"""Process all the nodes in the instance"""
if not instance.data.get("reuseLastVersion"):
return
frame_start = instance.data["frameStart"]
frame_end = instance.data["frameEnd"]
for repre in instance.data["representations"]:
files = repre["files"]
is_image_sequence = (
f".{repre['ext']}" in IMAGE_EXTENSIONS and
isinstance(files, list)
)
if not is_image_sequence:
self.log.debug(
f"Representation '{repre['ext']}' is not image sequence"
)
continue
collections = clique.assemble(
files,
)[0]
if len(collections) != 1:
raise KnownPublishError(
"Multiple collections {} found.".format(collections)
)
collection = collections[0]
used_version_entity, last_version_copied_files = (
fill_sequence_gaps_with_previous_version(
collection=collection,
staging_dir=repre["stagingDir"],
instance=instance,
current_repre_name=repre["name"],
start_frame=frame_start,
end_frame=frame_end,
)
)
if not last_version_copied_files:
raise KnownPublishError("Couldn't copy last version files.")
added_file_names = [
os.path.basename(file_path)
for file_path in last_version_copied_files.values()
]
repre["files"].extend(added_file_names)
# reset representation/instance to original length
repre["frameStart"] = used_version_entity["attrib"]["frameStart"]
repre["frameEnd"] = used_version_entity["attrib"]["frameEnd"]
instance.data.pop("hasExplicitFrames")
|
Process all the nodes in the instance
Source code in client/ayon_deadline/plugins/publish/global/extract_last_version_files.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 | def process(self, instance):
"""Process all the nodes in the instance"""
if not instance.data.get("reuseLastVersion"):
return
frame_start = instance.data["frameStart"]
frame_end = instance.data["frameEnd"]
for repre in instance.data["representations"]:
files = repre["files"]
is_image_sequence = (
f".{repre['ext']}" in IMAGE_EXTENSIONS and
isinstance(files, list)
)
if not is_image_sequence:
self.log.debug(
f"Representation '{repre['ext']}' is not image sequence"
)
continue
collections = clique.assemble(
files,
)[0]
if len(collections) != 1:
raise KnownPublishError(
"Multiple collections {} found.".format(collections)
)
collection = collections[0]
used_version_entity, last_version_copied_files = (
fill_sequence_gaps_with_previous_version(
collection=collection,
staging_dir=repre["stagingDir"],
instance=instance,
current_repre_name=repre["name"],
start_frame=frame_start,
end_frame=frame_end,
)
)
if not last_version_copied_files:
raise KnownPublishError("Couldn't copy last version files.")
added_file_names = [
os.path.basename(file_path)
for file_path in last_version_copied_files.values()
]
repre["files"].extend(added_file_names)
# reset representation/instance to original length
repre["frameStart"] = used_version_entity["attrib"]["frameStart"]
repre["frameEnd"] = used_version_entity["attrib"]["frameEnd"]
instance.data.pop("hasExplicitFrames")
|