ayon-core icon indicating copy to clipboard operation
ayon-core copied to clipboard

Enhancement: Allow running publish actions per instance

Open BigRoy opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Please describe the feature you have in mind and explain what the current shortcomings are?

The actions on the publish validation report will always run over all the failed instances.

That makes sense when the UI selection is like this where left side the header is selected. image

However, when selecting a single instance left side like this: image

Then suddenly it's weird that the Select Invalid and Regenerate UUIDs still run over ALL the instances instead of the ones selected in the UI.

How would you imagine the implementation of the feature?

Allow the repair actions to receive information from the active instances in the view.

Unfortunately it's somewhat a limitation of Pyblish's API as well:

class MyAction(pyblish.api.Action):
    def process(self, context, plugin):
        pass

With the process implemented like this unfortunately there's no argument that makes sense to come prefiltered.

Working around Pyblish's API limitations

There are some monkeypatching ways we can do it in OpenPype where we could:

  1. If an extra argument active_selection or selected_instances is added to the process method of an action then supply it with the UI active instances so the process method could filtering for those instances only.

  2. The code that is triggering the action could maybe secretly do:

action = MyAction()
action.selected_instances = selected_instances
action.process(context, plugin)

So that the plugin can do filtering like so:

class MyAction(pyblish.api.Action):
    def process(self, context, plugin):
        selected = getattr(self, "selected_instances", None)
        if selected is not None:
            # filter here
  1. If running through the UI we could also set a context.data["ui"]["selected_instances"] key - filtering would then be like above.

Are there any labels you wish to add?

  • [X] I have added the relevant labels to the enhancement request.

Describe alternatives you've considered:

As far as I know there are no current workarounds from the Action itself that we can do to get to this data.

Additional context:

No response

[cuID:OP-7221]

BigRoy avatar Oct 13 '23 12:10 BigRoy