Publisher2 non-blocking warnings

Hi everyone!

We are currently in the middle of transitioning from tk-multi-publish to tk-multi-publish2 and I was wandering if there is a good/default way to implement warnings that are “non-blocking”. Currently in the validation step you can either block the publish or let it pass. But we would like to implement some sanity-checks that tell the user that something could be wrong but publishes just fine.
Is this possible?

Cheers,
Fabian

3 Likes

You can log a warning, but that won’t stop the validation from passing.

I guess you want the user to be able to state that they are happy to ignore the warning.
I have a solution though it is clunky.

In your plugin you could have the following:

    def validate(self, settings, item):
        if not item.local_properties.get("ignore_bad_stuff", False):
            self.logger.warning("bad stuff", extra={
                "action_button":{
                    "label": "Ignore",
                    "tooltip": "Ignore this warning",
                    "callback": self._ignore_warning,
                    "args": {"item": item}
                },
            })
            raise Exception("bad stuff")
        return True


    def _ignore_warning(self, item):
        item.local_properties["ignore_bad_stuff"] = True
        print("ignoring", item)

This will create an error in the publish log with an ignore button. Once you’ve pressed that it will pass next time you validate.

Maybe there is an even better way that I haven’t thought of.

3 Likes

Hi Philip!

Thanks for your answer and cool idea! :slight_smile: Unfortunately it is not quite what we are looking for. I’ve made a small mock-up to give you an idea about what we have in mind. Maybe it sparks some idea :slightly_smiling_face:
image

So there would be another button beside the green check mark that tells the user something might be wrong. Clicking on it would bring him to the right line in the logging view where the user get’s more information (and maybe in the best-case scenario a way to fix the issue).

Thanks anyway for your help!

Cheers,
Fabian

1 Like

This is amazing. Thank you!

Hey @Fabian,

I realise this thread has been dead for a little while but I’m wondering if you ever managed to work out a way to do what you’re talking about in your example?

I’m looking to do something similar (ie have non blocking warnings be more obvious) and although I could implement @philip.scadding’s suggestion (which is a good work around) it would be great to know if there’s a more “vanilla” way to just display a warning icon during validation without having to make the actual validation fail.

Thanks
Tom

Hi @tom-fw !

Unfortunately we did not find any way of implementing this. I did not investigate this any further, because I have another idea of implementing some standalone “sanity check” tool that would leverage this publish hook:

Maybe that is also something for you to consider!? :slight_smile:

Cheers,
Fabian

1 Like

@Fabian Hey Thanks for the speedy reply!

That’s a shame… Never mind :slight_smile: I’ve just implemented @philip.scadding’s approach which does a good enough job of what I’m trying to achieve as an end goal.

Interesting! So you’re using that to just run a completely custom sanity checking UI/Module before it even gets to the point where the Publish UI is available? I think in my case that’s probably overkill but it’s good to know for the future if we need something a bit more complex :slight_smile:

Thanks
Tom

1 Like

Hi all. I was wondering how to to implement something simmilar and I have a question.

Is there an easy/build in way to create popup window in case of a warning?
I would like to implement @philip.scadding solution, but with a popup window instead ( to make it more user friendly)

Hi @Kemer3D !

I usually use the QMessageBox to display messages to the user:

from tank.platform.qt import QtGui
QtGui.QMessageBox.warning(None, 'Some error', 'Some error details')

Have a look at the PySide docs there are also other flavours of message boxes (like for errors, information or questions).

Hope that helps :slight_smile:

2 Likes

Lovely, thank you @Fabian!

1 Like