Skip to content

extract_headless_farm

ExtractRenderOnFarm

Bases: InstancePlugin

Copy the workfile to a timestamped copy.

Source code in client/ayon_nuke/plugins/publish/extract_headless_farm.py
10
11
12
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
class ExtractRenderOnFarm(pyblish.api.InstancePlugin):
    """Copy the workfile to a timestamped copy."""

    order = pyblish.api.ExtractorOrder + 0.499
    label = "Extract Render On Farm"
    hosts = ["nuke"]
    families = ["render_on_farm"]

    settings_category = "nuke"

    def process(self, instance):
        if not instance.context.data.get("render_on_farm", False):
            return

        host = registered_host()
        current_datetime = datetime.now()
        formatted_timestamp = current_datetime.strftime("%Y%m%d%H%M%S")
        base, ext = os.path.splitext(host.current_file())

        directory = os.path.join(os.path.dirname(base), "farm_submissions")
        if not os.path.exists(directory):
            os.makedirs(directory)

        filename = "{}_{}{}".format(
            os.path.basename(base), formatted_timestamp, ext
        )
        path = os.path.join(directory, filename).replace("\\", "/")
        instance.context.data["currentFile"] = path
        shutil.copy(host.current_file(), path)