pyblish / pyblish-base

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

actions raises an exception when running successfully #376

Closed hannesdelbeke closed 2 years ago

hannesdelbeke commented 2 years ago

actions seem to raise an exception when running successfully, depending on the state of the underlying plugin. i'd expect an action to finish successfully, and not depend on the state of the plugin it is linked too.

reproduction steps:

take the maya example from

https://api.pyblish.com/pyblish.api/action

add to the top of the example code:

import maya.cmds as cmds
cmds.polyCube()  # create cube1
pyblish.api.deregister_all_plugins()  # reset all plugins so we can rerun this code

run the example code

hannesdelbeke commented 2 years ago

output:

Using existing QApplication..
Installed opensans\OpenSans-Regular.ttf
Installed opensans\OpenSans-Semibold.ttf
Installed fontawesome\fontawesome-webfont.ttf
Installed translator
About to reset..
Processing Maya Workspace
Processing Maya Current File
Processing Current working directory
Processing Collect
Processing Current user
Processing Current date
Finishing up reset..
Finished successfully!
Finished successfully!

start validate continue output:

Preparing validate..
Processing Validate
// Error: pyblish.plugin : Traceback (most recent call last):
  File "C:\Projects\pyblish-base\pyblish\plugin.py", line 592, in __implicit_process
    provider.invoke(runner)
  File "C:\Projects\pyblish-base\pyblish\plugin.py", line 113, in invoke
    return func(**inject)
  File "<maya console>", line 41, in process
Exception: I failed
Traceback (most recent call last):
  File "C:\Projects\pyblish-base\pyblish\plugin.py", line 592, in __implicit_process
    provider.invoke(runner)
  File "C:\Projects\pyblish-base\pyblish\plugin.py", line 113, in invoke
    return func(**inject)
  File "<maya console>", line 41, in process
Exception: I failed // 
Stopped due to error(s), see Terminal.
Stopped due to error(s), see Terminal.

crash as expected now we run the action from the right click menu on the validator continue output:

plugin is: <class 'pyblish.plugin.Validate'>
Preparing <class '__main__.SelectInvalidNodes'>..
Action prepared.
// pyblish.pyblish.plugin.Action : Finding bad nodes.. // 
// pyblish.pyblish.plugin.Action : Selecting bad nodes: pCube1 // 
Stopped due to error(s), see Terminal.

as we can see from the output the action ran, and the mesh is selected so it seems to work. yet it says stopped due to error

instead of the last line saying Stopped due to error(s), see Terminal. i expect Finished successfully!

hannesdelbeke commented 2 years ago

on another (related) note: are actions somehow influenceing the CVEI process? when running an action on a plugin that has not run yet, the buttons in the GUI appear as if a validation was run image

update i believe this is done by changing state and state callbacks what i don't get is why sometimes it changes back and sometimes it doesnt. (depending on which action i run)

hannesdelbeke commented 2 years ago

when running action on a validator that ran successfully image it says Finished successfully

hannesdelbeke commented 2 years ago

the real problem starts when i try to add the action on my custom plugins. for some reason it starts to error out a lot. and i can't tell where it goes wrong because the error gives no info image

output

No local comment, reading from context..
Running with states.. ['errored', 'suspended', 'visible', 'clean', 'visibility', 'operation', 'alive', 'group', 'ready']
Entering state: "acting"
Entering state: "clean"
Entering state: "ready"
Entering state: "hidden"
# Error: pyblish.plugin : Traceback (most recent call last):
  File "C:\Projects\pyblish-base\pyblish\plugin.py", line 522, in __explicit_process
    runner(*args)
TypeError: process() takes exactly 2 arguments (3 given)
Traceback (most recent call last):
  File "C:\Projects\pyblish-base\pyblish\plugin.py", line 522, in __explicit_process
    runner(*args)
TypeError: process() takes exactly 2 arguments (3 given) # 
Entering state: "hidden"
Finished, finishing up..
Entering state: "alive"
Entering state: "clean"
Entering state: "ready"
Finished with states.. ['errored', 'suspended', 'clean', 'visibility', 'operation', 'alive', 'group', 'hidden', 'ready']
hannesdelbeke commented 2 years ago

the error TypeError: process() takes exactly 2 arguments (3 given) is fixed when changing def process(self, context): to def process(self, context, plugin):

why does this work in the example but not when hooking up to my plugin? confusing.

hannesdelbeke commented 2 years ago

i can't tell where it goes wrong because the error gives no info

i think this is probably the main issue i seem to have with using pyblish. silent crashes. by now i've realised that a plugin likely has some kind of issue but would be nice to get an exception. QML often just doesnt load a plugin when i'm working on it, and then i'm left to figure out why.

mottosso commented 2 years ago

Thanks for all your research and issue/pr submissions @hannesdelbeke! I'm back from holiday tomorrow and will dive into each and every one starting then.

mottosso commented 2 years ago

i think this is probably the main issue i seem to have with using pyblish. silent crashes.

True. One remedy is running plug-ins without a GUI and enabling debug logging. All logging defaults to INFO or WARNING since they are expected to most often run on an end-user (artist) environment.

pyblish publish --logging-level DEBUG

Is it safe to consider this issue part of the main issue at #374?

hannesdelbeke commented 2 years ago

i think i went a bit off topic here to highlight the silent fail is quite bothersome. let's try keep that discission in #374

the main issue here is why does the action work in the example but not when i hook it up to my plugin. unless i change def process(self, context): to def process(self, context, plugin):

mottosso commented 2 years ago

I don't think it should work without plugin since that's the argument signature it's expecting.

Could it be falling back to the "implicit" method, i.e. the old-style of doing things?

hannesdelbeke commented 2 years ago

ah in that case the example is simply outdated. let's not focus on why it works, if we are not supposed to work that way anymore.

so i guess this can be closed then

hannesdelbeke commented 2 years ago

the example action SelectInvalidNodes in the 1.6 doc only takes a context arg, no plugin arg. https://api.pyblish.com/pyblish.api/action

it would be great though if an action could run without a plugin, to allow for more flexibility.

mottosso commented 2 years ago

it would be great though if an action could run without a plugin, to allow for more flexibility.

I can't think of a usecase, or even how that could work in practice, as actions are only accessible as part of a plug-in? And it's safe to simply not use the provided plugin argument.