[solved] Collection sorting


#1

Working with many instances in the GUI list, can be difficult when they are sorted by the collectors. I’m sorting the context here by family and name;

import pyblish.api


class CollectSorting(pyblish.api.Collector):

    order = pyblish.api.Collector.order + 0.4

    def process(self, context):

        context[:] = sorted(context,
                            key=lambda instance: (instance.data("family"),
                                                  instance.data("name")))

Question is whether we would wanted this by default in Pyblish?


[solved] Grouping instances base on their family
#2

That’s a good question.

Currently, you control the order; either when/how you create instances, or by running something like this at the tail end of collecting.

The problem with having it automatically happen is that you’ll loose this control when you need it.

How do others feel about giving up that level of control? Do you use it?


#3

Another important point is that this also affects the order in which plug-ins are physically processed. That could be useful in some cases, in case one instance somehow depends on another.


#4

And finally (I hope :)) this also mean we’ll lose out on any future ability to move instances around in the GUI to change their order.


#5

Good points:)

People can use this if they want to.


#6

Yes, that is a great way of handling it I think. :slight_smile:


#7

After the feature of visualisting collection, this has stopped working. It seems that the GUI keeps its sorting order from when the instances gets added to the context, and ignoring any context reordering post-collection.


#8

This sounds like a bug.

Have a look at adding a test for this in pyblish-qml. There are a few examples there to light the way. If a solution doesn’t pop out to you, I’ll try and take a look at this once the test captures the problem.


#9

#10

Thanks, but a unit-test would be preferable.

Try and reproduce the problem as a test, then we can have a look at passing that test.


#11

Here we go:)


#12

Marking this as solved, due to latest PR to pyblish-qml.


GUI Context Reordering