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

Pyblish fails when it tries to process InstancePlugin with typo process argument "instance" #350

Open
BigRoy opened this issue Sep 11, 2019 · 3 comments

Comments

@BigRoy
Copy link
Member

BigRoy commented Sep 11, 2019

Issue

Whenever you implement a pyblish.api.InstancePlugin with a process method that does not have the argument instance but it's written differently/wrong then Pyblish QML will raise the following assertion error:

Traceback (most recent call last):
  ...
  File "D:\pyblish_qml\ipc\server.py", line 280, in _listen
    result = wrapper(func, *args)  # block..
  File "D:\pyblish_qml\host.py", line 41, in _wrapper
    raise e
AssertionError: Cannot process an InstancePlugin without an instance. This is a bug

For example, the following will reproduce this error:

import pyblish.api


class Collector(pyblish.api.InstancePlugin):
    order = pyblish.api.CollectorOrder

    def process(self, wrong):
        pass

Notice how the argument is wrong as opposed to instance.

Similarly context fails on an InstancePlugin too with the same error:

import pyblish.api


class Collector(pyblish.api.InstancePlugin):
    order = pyblish.api.CollectorOrder

    def process(self, context):
        pass

Proposal

It would be great if the error would be resolved into a message describing which plug-in is faulty with some information for the developer on how to potentially resolve it.

Reference:


I've also tried to reproduce the other way around with pyblish.api.ContextPlugin but it doesn't run into the same issue, however does have an issue of its own which should be a separate issue than this, see pyblish/pyblish-qml#339.

@BigRoy BigRoy transferred this issue from pyblish/pyblish-qml Sep 11, 2019
@BigRoy BigRoy changed the title Pyblish QML fails when it tries to process InstancePlugin with typo process argument "instance" Pyblish fails when it tries to process InstancePlugin with typo process argument "instance" Sep 11, 2019
@BigRoy
Copy link
Member Author

BigRoy commented Sep 11, 2019

Transferred this from pyblish-qml to pyblish-base. Here's the stack trace from pyblish-base:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "D:\git_pipeline\avalon\development\git\pyblish-base\pyblish\util.py", line 193, in collect
    for result in collect_iter(context, plugins, targets):
  File "D:\git_pipeline\avalon\development\git\pyblish-base\pyblish\util.py", line 252, in collect_iter
    context, plugins, targets):
  File "D:\git_pipeline\avalon\development\git\pyblish-base\pyblish\util.py", line 300, in _convenience_iter
    for result in publish_iter(context, plugins, targets):
  File "D:\git_pipeline\avalon\development\git\pyblish-base\pyblish\util.py", line 119, in publish_iter
    result = plugin.process(Plugin, context, instance)
  File "D:\git_pipeline\avalon\development\git\pyblish-base\pyblish\plugin.py", line 460, in process
    result = __explicit_process(plugin, context, instance, action)
  File "D:\git_pipeline\avalon\development\git\pyblish-base\pyblish\plugin.py", line 479, in __explicit_process
    raise AssertionError("Cannot process an InstancePlugin without an "
AssertionError: Cannot process an InstancePlugin without an instance. This is a bug

Tested with the above example plug-ins and running the following:

import pyblish.util
pyblish.util.collect()

@hannesdelbeke
Copy link
Contributor

moving your repro steps all in one block of code:

import pyblish.api
import pyblish.util

class Collector(pyblish.api.InstancePlugin):
    order = pyblish.api.CollectorOrder

    def process(self, context):
        pass
        
pyblish.api.register_plugin(Collector)
pyblish.util.collect()

prints:

# Error: AssertionError: file C:\Projects\pyblish-base\pyblish\plugin.py line 490: Cannot process an InstancePlugin without an instance. This is a bug # 

@hannesdelbeke
Copy link
Contributor

hannesdelbeke commented Jan 15, 2022

would simply changing

raise AssertionError("Cannot process an InstancePlugin without an ""instance. This is a bug." )

to

raise AssertionError("Cannot process an InstancePlugin without an ""instance. This is a bug. Affected plugin:" + str(plugin))

be enough to resolve this?
output for your example now tells you which plugin it fails on.
# Error: AssertionError: file C:\Projects\pyblish-base\pyblish\plugin.py line 491: Cannot process an InstancePlugin without an instance. This is a bug. Affected plugin:<class 'pyblish.plugin.Collector'>#

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

No branches or pull requests

3 participants