Pyblish: register_host

64 views
Skip to first unread message

Miguel González Viñé

unread,
Jun 4, 2018, 8:03:17 AM6/4/18
to python_inside_.
Hi all,

I'm trying to understand pyblish and I'm getting a problem just at the beginning :) 

I want to get this example working ( https://gist.github.com/mottosso/93399862c94f0ab4314f ) but substituting pyblish_maya by my own.

So I register the host through a function like pyblish_maya.setup() but they don't show as registered hosts outside my function.

I wrote in the script editor:
import fbShotGum.publish
fbShotGum.publish.register_host()

where  fbShotGum.publish.register_host() is:
def register_host():
    """Register supported hosts"""
    print(pyblish.api.registered_hosts())
    pyblish.api.register_host("mayabatch")
    pyblish.api.register_host("mayapy")
    pyblish.api.register_host("maya")
    print(pyblish.api.registered_hosts())

and I get this output:
['python']
['python', 'mayabatch', 'mayapy', 'maya']

but now if I write:
import pyblish.api
pyblish.api.registered_hosts()

I only get ['python']

So when I try to register the "ExtractRig" plugin like in the "Learn Pyblish By Example - Quickstart 1.4" example, I can't because "maya" host is not registered. 

I suppose they are in different scopes? But I'm just trying to follow that example. So what I'm doing wrong?

Thank you,
Miguel

Marcus Ottosson

unread,
Jun 4, 2018, 1:26:34 PM6/4/18
to python_in...@googlegroups.com

Hey Miguel,

Happy to answer questions here, just want to point out that we have a dedicated forum for questions surrounding Pyblish here:

Just so we’re seeing the same thing, here’s what I’ve done to set things up.

Microsoft Windows [Version 10.0.17134.48]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\marcus
$ mkdir pyblish
$ cd pyblish
$ c:\Python27\python.exe -m pip install pyblish-base pyblish-maya --target .
Collecting pyblish-base
Collecting pyblish-maya
...
Successfully installed pyblish-base-1.6.1 pyblish-maya-2.1.4
$ set PYTHONPATH=%cd%
$ "c:\Program Files\Autodesk\Maya2018\bin\maya.exe"

Next I ran the entire script you linked to in Maya’s Script Editor, and here’s what I got.

pyblish.util.publish()
pyblish: Registered C:\Users\marcus\pyblish\pyblish_maya\plugins
Pyblish loaded successfully.
# pyblish.ExtractRig : Exporting Bruce to C:\Users\marcus\maya\scenes\temp\20180604T181853Z\rig\Bruce\Bruce.ma # 
# pyblish.IntegrateRig : Computing output directory.. # 
# pyblish.IntegrateRig : Copying C:\Users\marcus\maya\scenes\temp\20180604T181853Z\rig\Bruce to C:\Users\marcus\maya\scenes\public\v003.. # 
# pyblish.IntegrateRig : Copied successfully! #

Now, to your question, the host attribute is one you can use to filter a series of plug-ins with. For example, if you have plug-ins on your PYBLISHPLUGINPATH for both Maya and Nuke, then putting ["maya"] as a host for your plug-in would cause this plug-in to only run if the host maya has been registered.

class ExtractRig(pyblish.api.InstancePlugin):
  order = pyblish.api.ExtractorOrder
  families = ["rig"]
  hosts = ["maya"]

At the top of the script, there is a call to pyblish_maya.setup() which leads to here:

And that in turn is what registers maya as a host, and is what causes that ExtractRig plug-in to get through the filter.

If you replace that call with your registerHosts() function..

# Install Pyblish for Autodesk Maya
#pyblish_maya.setup()


def register_host():
    """Register supported hosts"""
    print(pyblish.api.registered_hosts())
    pyblish.api.register_host("mayabatch")
    pyblish.api.register_host("mayapy")
    pyblish.api.register_host("maya"
)
    print(pyblish.api.registered_hosts())

register_host()

...

..you should be seeing the same output as above.

Could you try this and let me know what you get?

Best,
Marcus

Miguel González Viñé

unread,
Jun 6, 2018, 5:58:14 AM6/6/18
to python_inside_.
Hi Marcus,

thank you for your long answer and sorry for my late reply. I totally forgot the forums, sorry.

I've followed all your steps and it works as expected. So I went to my scripts to see where's the problem and I've found something that I didn't know why it happens.
I've starting to write a long email explaining you step by step all what I do, and now I've just found how to solve it. I was including the pyblish module inside my modules instead of treat them as separate module, and something didn't like it.

So thank you so much for your time. And the next time I'll go straight to the forums.

Best,
Miguel

(Btw, how do you write that beautiful formatting code in the email? :) )


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCmzZa91rj3U0s7Qcj%3DcZqjGz_384Kebq%3DL%2BTqyGe-ovg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Jun 6, 2018, 6:29:09 AM6/6/18
to python_in...@googlegroups.com

Happy to hear you got it sorted!

(Btw, how do you write that beautiful formatting code in the email? :) )

It’s via a Chrome extension called “Markdown Here”


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABbyGYwJ0w1ejSNEJiGn2dzDLXtQ01f23zqfD4Rj21jXuT970Q%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages