Publish2 validate a single task

Cheerio folks,
I’m trying to impplement a way of validating only a single task from the Publish2 app inside of Maya.

My initial try was to create a custom ui for that task with one button. I pointed the clicked callback of that button to the validate function of the task. This works perfectly fine however it does not update the UI of the PublishTreeWidget as it would when executing a full validation process.

I’m currently trying to execute the PublishManager's validate funnction with a custom generator yielding only the desired task. However, I don’t quite get it to update the UI :confused:

Any ideas on how to achieve this?


I think I’m on the right track thanks to this post:

I’ll keep you posted and share some code once I have something working :slight_smile:


Glad you found the info you were after @tonyd! Looking forward to seeing the working code. :slight_smile: Best of luck!


Ok so here’s what I got…
The idea is to add a custom GUI with just a single button “Validate Me” that connects to single_validation on clicked.

def single_validation(self):
    # create a new publish manager instance
    manager = PublishApp.create_publish_manager()  # sgtk.platform.current_engine().apps.get("tk-multi-publish2")

def single_task_generator(self):
    is_standalone = True  # indicates that no Publish phase will follow
    for ui_item in self.__single_task_validate_generator():
            # yield each child item to be acted on by the publish api
            if isinstance(ui_item, TreeNodeTask):
                (is_successful, error) = yield ui_item.task
                error_msg = str(error)

            # all other nodes are UI-only and can handle their own validation
                is_successful = ui_item.validate(is_standalone)
                error_msg = "Unknown validation error!"
        except Exception as e:
            ui_item.set_status(ui_item.STATUS_VALIDATION_ERROR, str(e))
            if is_successful:
                if is_standalone:
                ui_item.set_status(ui_item.STATUS_VALIDATION_ERROR, error_msg)

def __single_task_validate_generator(self):
    for ui_item in self.__tree_ui_items():
        # if self._stop_processing_flagged:
        #     # jump out of the iteration
        #     break

        if not ui_item.checked:

        # self._progress_handler.push(
        #     "%s: %s" % (stage_name, ui_item,),
        #     ui_item.icon,
        #     ui_item.get_publish_instance(),
        # )

            yield ui_item
        except Exception as e:
        # finally:
        #     self._progress_handler.increment_progress()
        #     self._progress_handler.pop()

This is basically just copy/pasted from tk-multi-publish2 --> --> _validate_task_generator(), _task_generator(), _get_tree_items().

To be able to acces the Publisher’s UI I simply added self.widget = widget to the DCC’s show_dialog method just before it returns.
I don’t know if this has any downsides since this was considered as not that easy in the post i referenced earlier. Maybe someone of you folks knows a better way of accessing app ui’s from hooks?


Hi Tony

We don’t have anyway to access the main UI from within the hooks, at least not without modifying the app its self or going via hacky private variables.
The only part of the UI that is intended to be customizable is the plugin panel.

What your trying to do is a cool idea though!

1 Like