pyblish / pyblish-base

Pyblish base library - see https://github.com/pyblish/pyblish for details.
Other
127 stars 59 forks source link

Include "context" with the pluginProcessed event data #391

Open BigRoy opened 2 years ago

BigRoy commented 2 years ago

Issue

Currently the pluginProcessed event does not include the context which makes it impossible to 'debug' data in it whenever a plug-in was processed that did not include an instance. It currently matches the result of pyblish.plugin.process().

Would it be problematic if we would include context in the process() results or potentially add context just to the result of the emitted event. Why, or why not?

Additional info

Being able to access the context would allow debugging like this Github Gist does without hacking like this:

        # Don't tell me why - but the pyblish event does not
        # pass along the context with the result. And thus
        # it's non trivial to debug step by step. So, we
        # get the context like the evil bastards we are.
        i = 0
        found_context = None
        current_frame = inspect.currentframe()
        for frame_info in inspect.getouterframes(current_frame):
            frame_locals = frame_info.frame.f_locals
            if "context" in frame_locals:
                found_context = frame_locals["context"]
                break
            i += 1
            if i > 5:
                print("Warning: Pyblish context not found..")
                # We should be getting to the context within 
                # a few frames
                break

Which is slow, unsafe and not explicit behavior - it's basically a hack currently. It works in Maya, but crashes e.g. Nuke.