SG Publishing via Houdini Hython

I’m trying to push the farm_wrapper farm based publishing approach to our Houdini setup but I’ve hit a brick wall getting it to work within a Hython session.

If I add the usual paths to sys.path to enable importing of sgtk and run from sgtk.platform.qt import QtCore, QtGui I get the error “Cannot import name QtCore”.
This same code works fine inside Houdini.

When I submit the farm publish to Houdini, the SG Publisher is failing with the following code. Interestingly, the same code is working fine on Nuke and Maya which are also running in cmdline mode (eg no GUI).

[INFO farm_wrapper] Publish registered!
2020-02-24 05:45:54: 0: STDOUT: main()
2020-02-24 05:45:54: 0: STDOUT: File “//lic01/deadline/dev/deadline10-Username\custom\plugins\GlobalSGPublish.py”, line 227, in main
2020-02-24 05:45:54: 0: STDOUT: publish_items(engine, app_name, publish_tree_file)
2020-02-24 05:45:54: 0: STDOUT: File “//lic01/deadline/dev/deadline10-Username\custom\plugins\GlobalSGPublish.py”, line 188, in publish_items
2020-02-24 05:45:54: 0: STDOUT: manager.publish(generator(manager.tree))
2020-02-24 05:45:54: 0: STDOUT: File “C:\Users\Username\AppData\Roaming\shotgun\bundle_cache\app_store\tk-multi-publish2\v2.3.3\python\tk_multi_publish2\api\manager.py”, line 348, in publish
2020-02-24 05:45:54: 0: STDOUT: self._process_tasks(task_generator, lambda task: task.publish())
2020-02-24 05:45:54: 0: STDOUT: File “C:\Users\Username\AppData\Roaming\shotgun\bundle_cache\app_store\tk-multi-publish2\v2.3.3\python\tk_multi_publish2\api\manager.py”, line 240, in _process_tasks
2020-02-24 05:45:54: 0: STDOUT: return_value = task_cb(task)
2020-02-24 05:45:54: 0: STDOUT: File “C:\Users\Username\AppData\Roaming\shotgun\bundle_cache\app_store\tk-multi-publish2\v2.3.3\python\tk_multi_publish2\api\manager.py”, line 348, in
2020-02-24 05:45:54: 0: STDOUT: self._process_tasks(task_generator, lambda task: task.publish())
2020-02-24 05:45:54: 0: STDOUT: File “C:\Users\Username\AppData\Roaming\shotgun\bundle_cache\app_store\tk-multi-publish2\v2.3.3\python\tk_multi_publish2\api\task.py”, line 147, in publish
2020-02-24 05:45:54: 0: STDOUT: self.plugin.run_publish(self.settings, self.item)
2020-02-24 05:45:54: 0: STDOUT: File “C:\Users\Username\AppData\Roaming\shotgun\bundle_cache\app_store\tk-multi-publish2\v2.3.3\python\tk_multi_publish2\api\plugins\publish_plugin_instance.py”, line 198, in run_publish
2020-02-24 05:45:54: 0: STDOUT: self._hook_instance.publish(settings, item)
2020-02-24 05:45:54: 0: STDOUT: File “C:\PROGRA~1\SIDEEF~1\HOUDIN~1.293\python27\lib\contextlib.py”, line 24, in exit
2020-02-24 05:45:54: 0: STDOUT: self.gen.next()
2020-02-24 05:45:54: 0: STDOUT: File “C:\Users\Username\AppData\Roaming\shotgun\bundle_cache\app_store\tk-multi-publish2\v2.3.3\python\tk_multi_publish2\api\plugins\publish_plugin_instance.py”, line 296, in _handle_plugin_error
2020-02-24 05:45:54: 0: STDOUT: QtCore.QCoreApplication.processEvents()
2020-02-24 05:45:54: 0: STDOUT: AttributeError: ‘NoneType’ object has no attribute ‘QCoreApplication’

Can you advice on how to get SG Publish_Manager to work in a Houdini commandline session (eg hython).
Or, is this not supported?

Thanks in advance for any suggestions.
p.

3 Likes

Hello!

Patrick and I have been discussing this one offline, but I wanted to come back here with an update in case others are seeing it.

First some background: @jfboismenu did a webinar in Nov of 2018, demoing the Publish API, which allows you to perform “headless” publishes – executing publish code independent of the GUI (for example, for running publishes on the farm). He provided the code for his demo in the tk-config-publish_api_webinar repo here., and Patrick’s workflow above is based on that demo.

The Toolkit Engine class has a has_ui() method, and the tk-houdini engine does implement it properly.

Patrick was seeing the following error:

2020-02-24 05:32:15: 0: STDOUT: File "S:\path\to\pipeline\configuration\tk-config-default2\hooks\tk-multi-publish2\basic\farm_wrapper.py", line 20, in <module>
2020-02-24 05:32:15: 0: STDOUT: class FarmWrapperWidget(QtGui.QWidget):

Because this is in the hook code on the studio’s end, he was able to fix that by wrapping the class declaration in farm_wrapper.py in the following if statement:

if sgtk.platform.current_engine().has_ui

But there’s also the error in the original post above, and that is very much coming from our code. That one looks like a bug. The code looks like this:

So, it looks like the not in the if statement is in error. We’re tracking that as a bug, and if the issue is as simple as it looks, hopefully we’ll have a fix out soon!

1 Like

I wrote this…
image

2 Likes

image

Haha. Can’t say I’m not guilty of throwing nots where they’re not wanted from time to time. I try to explicitly compare with booleans these days so my little brain doesn’t get all confused. Not sure if that’s considered best pythonic practice these days but it can’t hurt I suppose!

3 Likes

Yeah, I think what you are saying is actually a good practice. I’ve started writing a lot of conditionals like this recently:

if something is False: # Black will frown on us if we use == 😉.

It avoids the not trap and also IMHO it reads better since it reads just like you would say it out loud if you were speaking to someone.

Hello, just wanted to let you know that the above bug has been fixed. You can get the fix in v2.5.0 of `tk-multi-publish2. @Patrick, thanks again for helping track that down!

2 Likes