Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error with the silent non-GUI publish #44

Open
srikanthpotipi opened this issue Oct 22, 2023 · 4 comments
Open

error with the silent non-GUI publish #44

srikanthpotipi opened this issue Oct 22, 2023 · 4 comments

Comments

@srikanthpotipi
Copy link

srikanthpotipi commented Oct 22, 2023

I see an error when I try to run File --> Publish
But the UI launches fine (File --> Publish...)

Nuke 14

Is anyone else facing the issue? Looks like the issue is with the callback

Traceback (most recent call last):
  File "D:\<>\pipe-20\.venv\Lib\site-packages\pyblish\lib.py", line 273, in emit
    callback(**kwargs)
  File "D:\<>\pipe-20\.venv\Lib\site-packages\pyblish_nuke\lib.py", line 195, in on_published
    for r in context.data["results"]:
AttributeError: 'NoneType' object has no attribute 'data'
@mottosso
Copy link
Member

Thanks for reporting this, help to solve it is most welcome, here's the line at the time of this issue.

errors = False
for r in context.data["results"]:
if r["error"]:
errors = True

@srikanthpotipi
Copy link
Author

@mottosso
Thanks for responding.

I tried to fix this by adding a check if context exists. It works with that. But ideally the context shouldn't be empty. Curious on the internals of this

But I am trying to understand more about Pyblish and how callbacks work, data sharing, etc. Any links would be really appreciated

@mottosso
Copy link
Member

Yes, the context should not be empty. In theory it couldn't be, as without a context there can't be any publishing. So this is a bug somewhere.

Here's the documentation.

If we follow the breadcrums:

  1. Nuke calls util.publish_iter():
    for result in util.publish_iter():
  2. Which then calls api.emit("published", context=context)
  3. Which finally calls the provided callback def on_published(context):
    def on_published(context):

Only the problem is, no context is given from Nuke. So the solution seems to be to simply create a new context in Nuke, and pass that to publish_iter.

This is what is expected of publish_iter.

def publish_iter(context=None, plugins=None, targets=None):
    # ...
    context = api.Context() if context is None else context
    plugins = api.discover() if plugins is None else plugins

@mruegenberg
Copy link
Contributor

I seems the underlying problem is that in _convenience_iter in util.py of pyblish-base, a new context is created on demand, but not passed back to where it's called in publish_iter.
So if context=None in publish_iter, that's passed to the api.emit("published", context=context) call, even though in the meantime a new context was created.

I'm happy to create a PR either on pyblish-base adressing this if it's likely to be merged, or add your described workaround here on pyblish-nuke, which would maybe be less clean, but avoid changing the base package :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants