-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add 'context' key to 'result' dict #401
Add 'context' key to 'result' dict #401
Conversation
Yes - this would be great. This would make |
Sorry for the delay I must have forgot to hit "Comment". This should work fine, my only concern is with cyclic dependencies. I recall there was a reason for not including this, but can't recall exactly what. It did involve recursion and memory bloating. If you can confirm that no references to itself exist in the result that would help alleviate this issue. For example, the instance contains reference to the context, which contains reference to each instance.. I can't be sure. Can we list out the dependencies here so we know? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memory bloating
Ouch!
Can we list out the dependencies here so we know?
I'm not sure how to do that but I did some test. I hope it's relevant.
As far as I understood we have two cases:
- If the processed plugin is an instance plugin. in which
result["instance"].context
is the same asresult["context"]
which is duplicate data. So, it's redundant to pass the context in this case ? - If the processed plugin is a context plugin. in which there are no instances passed therefore
result["instance"].context
doesn't exist.
I tested the suggestions below using BigRoy's pyblish stepper.
Here's a portion of the log:
<<<<<<<<<< CollectWorkfile >>>>>>>>>>
result["instance"]: workfileCfx
result["instance"].context: [pyblish.plugin.Instance("reviewMain"), pyblish.plugin.Instance("workfileCfx")]
result.get("context"): None
<<<<<<<<<< CollectCurrentDate >>>>>>>>>>
result["instance"]: None
Skipping result["instance"].context
result.get("context"): [pyblish.plugin.Instance("reviewMain"), pyblish.plugin.Instance("workfileCfx")]
Mm, true, this is already a cycle, as the context then also includes the instance which includes the context etc. So it mustn't be an issue to add another then. Then this looks fine to me, I'm happy to merge this once you are happy. |
Great, thanks a ton! I'm really happy indeed.
|
Changelog Description
This PR adds
context
key toresult
dict insideplugin.process
Additional Info 1
This PR is very helpful for people who develop some debugging tools like https://gist.github.com/BigRoy/1972822065e38f8fae7521078e44eca2
This PR avoids the need to create custom redundant events.
Additional Info 2
Things I tried:
result["instance"].context
but this only works for instance plugins.lib.emit("pluginProcessed", result=result, context=context)
but apparently this affects every single call so we will get an errorTypeError: on_plugin_processed() got an unexpected keyword argument 'context'