Render farm publish tree only publish checked items

Hello,

I’ve followed this tutorial to set up a farm job wrapper hook that allows me to only run certain publish tasks on the farm using this script to rebuild and run the publish tree on a render node.

However, it seems that the publish tree description file does not store information about whether or not a given publish plugin is checked and runs its publish tasks anyway. For example, if I un-check “Publish to Shotgun” it still gets written to the publish tree file and executed on the render farm.

image

This is the generator used to yield the tasks that need to be executed:

def generator(tree):
    """
    Yields tasks that have the "Submit to Farm" setting set to True.
    """
    for item in tree:
        for task in item.tasks:
            if task.checked:
                if "Submit to Farm" in task.settings \
                        and task.settings["Submit to Farm"].value is True:
                    yield task

My question would be how can I ensure it doesn’t return any tasks that were not checked in the UI. So far I have tested item.active, item.checked, task.checked, task.active, task.enabled, which all seem to return True.

Any advice would be most welcome!

3 Likes

So I checked my original scene’s publish tree and confirmed that even if my UI items are un-checked, the PublishItem instances the tree contains are still marked as checked and active.

Capture2

I found that the tasks to be publish are yielded by this generator. It seems that only the UI items are marked as checked and not the PublishItems themselves. I may be wrong, but if not, any ideas on how to implement a method where each UI item’s checked state change is stored in the corresponding PublishItem instance as well?

2 Likes

I think that you can skip non-checked (non active) items in generator like this:

for item in tree:
        # skip unchecked publish items
        if not item.active:
            continue
4 Likes

Sorry. I forget that this will work only after small correction in tk-multi-publish2 source,
that we have used in our studio, and placed in shotgun git repository as pull-request some time ago…
[https://github.com/shotgunsoftware/tk-multi-publish2/pull/105]( Connect PiblishItem UI checked, enabled state #105)

4 Likes

Thanks @ymesh, you’ve pointed me in the right direction.

Setting the PublishItem to checked based on the UI item’s checked signal is great, but it doesn’t account for its PublishTask children. For example, the top level item can be checked, but all but one of its tasks could be checked so these should not be executed.

With a slight modification of your changes, this is my solution.

And this is my updated generator:

def generator(tree):
    """
    Yields tasks that have the "Submit to Farm" setting set to True.
    """
    for item in tree:
        if not item.checked:
            continue
        for task in item.tasks:
            if not task.active:
                continue
            if "Submit to Farm" in task.settings \
                    and task.settings["Submit to Farm"].value is True:
                yield task
1 Like

On this note, I think this functionality is fairly useful and to be expected. It would be great if it’s implemented in the official Shotgun tk-multi-publish2 app, perhaps something for the Shotgun dev team to look into :slight_smile:

2 Likes

Hey Viktor,

Have you checked the SG roadmap.
Here you can submit your ideas and also check what solutions are considering or already in progress :wink:

Cheers!

5 Likes

Thanks @Linda, done!

3 Likes

Cool :sunglasses:! You are welcome!

2 Likes

Hey @ymesh, thanks for sharing that PR! We have a ticket logged already internally to look at this bug, so I’ve linked that up with your PR.

3 Likes

Thanks, Philip! It would be great to have this functionality in next tk-multi-publish2 update,
instead of keeping custom forks for very simple enhancements )))

1 Like