Exiting tk-multi-publish2 at error during collection

Hi there,

I’d like to be able to exit the Publisher app (tk-multi-publish2) if there is an error during collection. However, at the moment, I have the below code which raises a confirm dialog in Maya with the error details, but the raise statement for the CollectionError doesn’t stop execution of the app. Once the confirm dialog is closed, the publisher window still comes up.

    try:
        # ~~~~~~~Collecty stuff~~~~~~~~
    except Exception:
        error_msg = "ERROR DURING COLLECTION: %s" % traceback.format_exc()
        cmds.confirmDialog(title="Collector Error",
                           message=error_msg,
                           button=["OK"])
        raise CollectionError(error_msg)

Is there any way to stop the publisher from executing if this code is reached?

Thanks!

1 Like

Hi Rob

I’ve spent a bit of time looking into this, but I don’t believe there is a way via the hook.
In order to close the app you would need to call the close() method on the QT dialog, and there doesn’t appear to be a way to get a handle to that.

I’ll check with the team though in case I’ve missed anything.

Thanks
Phil

2 Likes

I had a chat, but unfortunately, I don’t think there is a way, this would need to be a feature request.
You can submit an idea here. Maybe there is some other way of working around it, although it maybe less elegant.

1 Like

Thanks for looking into it Philip, I appreciate your work on this!

It’s a little disappointing - if we run into an issue during collection, we can’t stop the Publish tool appearing and if we have an artist that isn’t paying attention, they might only manage a partial publish, as they will still be displayed with a similar window even in the event of an error during collection. Without the error box popup, the error might even pass unnoticed (as I believe the default is to output something in the Maya script editor output window, but still open the Publish tool. Not ideal behaviour.

1 Like

Yeah I can understand that, in order to proceed the collection must have completed correctly.

Could you modify the validation of the plugins to ensure that all items have been correctly collected before proceeding?

This I appreciate might not be as elegant, as

  1. You would need to add this logic to all plugins that you are using.
  2. The user will have already potentially added a description, taken a screen grab and filled in any other custom settings by this point which could have been avoided.
1 Like

The issue I expect to run into is that, if there’s an error collecting items from a scene for Texturing/Surfacing and there’s an error in collecting the textures from the shading network, this might be because there are no textures used in the shading network OR because there was an error during collection. So the publisher would still look the same to the artist. And there’s no opportunity to put in the validation to make sure the textures are collected unless I put it in every plugin, even ones that don’t relate to textures.

This example is just off the top of my head and probably slightly contrived, but you can see where we might run into this in a few edge cases, so it’ll be difficult to work around.

But thanks for the info and the time you spent on this, I appreciate you looking into it.

2 Likes

Hi Rob

I just chatted to @manneohrstrom to see if he had any other suggestions, and he came up with a couple of other ideas. It’s fair to say these are also a bit clunky but they might work for you.

  1. If you can’t collect all the items that you would wish to collect inorder to perform a valid publish, then you could choose not to collect any of them at all, and instead collect a faux item, called “error item” or something. Perhaps that item could then have a plugin that explained the reason for the error.

  2. Another approach is to use the publish API to run the collection prior to launch the app to see if the valid items can be collected, and then if they can let the publish app launch and run the collection again. This is probably more clunky though as you would need to write a wrapper app for the publisher that performed this check prior to launching the actual app.

Thanks
Phil

2 Likes

Hi Philip,

Those are both interesting options, the second one might be less work to implement - I could make it a shelf button in Maya that ran the check first before launcing the Publish app proper.

Thanks for sharing that!

2 Likes