pyblish / pyblish-base

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

Add 'context' key to 'result' dict #401

Closed MustafaJafar closed 1 month ago

MustafaJafar commented 1 month ago

Changelog Description

This PR adds context key to result dict inside plugin.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:

BigRoy commented 1 month ago

Yes - this would be great.

This would make context easily accessible from the pluginProcessed event callback which is the reason you're making this change but wasn't extremely apparent from the PR description.

mottosso commented 1 month ago

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?

mottosso commented 1 month ago

result["instance"].context

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.

MustafaJafar commented 1 month ago

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.

Would you recommend the previous suggestions ? Or the PR as it's looks good ? Oh, My question was already answered!

So it mustn't be an issue to add another then.