Open davidlatwe opened 5 years ago
I think this PR also resolved @mottosso 's little worry in #347. 😉
I think I need to explain my motivation on proposal 2 a little :
One of my plugins was checking on current targets so to filter out instances in working scene by family, before instance is created.
For example, I have a context plugin which responsible to create instances and runs in all targets, and if the current target is "remote publish", then I don't want instance which it's family is like model
or rig
being created at first place. So I would need to firstly checking on current targets, then avoid those families instances.
For example, I have a context plugin which responsible to create instances and runs in all targets, and if the current target is "remote publish", then I don't want instance which it's family is like
model
orrig
being created at first place. So I would need to firstly checking on current targets, then avoid those families instances.
Could you do the same workflow but just inherit a plugin class and changing the target? I may not see the use-case correctly.
Could you do the same workflow but just inherit a plugin class and changing the target?
Yes, it still can be done with current mechanism, but have to write a bit more code.
Anyway, the example above was not the main problem, it's not a "must-solve" issue, but could solve better if proposal 1 has implemented. So the point still is the Problem 1.
Also note that, this PR will NOT change any current features, only tweaked the internal data flow.
Problem 1
The plugins was
discover
in parent-process (server side), and formatted into JSON then send to child-process (client side), next, theplugins_by_targets
logic was handled there.So say we have 10 plugins total, 5 for target "A" and the other 5 for target "B". In current data workflow described above, there's high chance that server is sending all 10 plugins into client and filter out 5 plugins which won't needed. Which I think can be improved.
Proposal 1
Moving the target filtering process from client to server.
Problem 2
In #335, @BigRoy mentioned:
In this design, in other words, you can not trust
pyblish.api.registered_targets
inside plugin which runs inpyblish-qml
.Proposal 2
Implement targets query function into
pyblish_qml.api
.pyblish_qml.api.current_targets
And with proposal 1 implemented, we can spend no more server-client communication for querying current targets.
Extra Proposal
I often used
pyblish_qml.api.current_server().service._context
to get thepyblish.api.Context
object inpyblish_qml
session.So I propose to implement a convenient function for that propose as well.
pyblish_qml.api.current_context