Offsetting default order by 0.5

At the moment, you can offset a plug-in from it’s default order by incrementing it.

import pyblish.api

class MyValidator(pyblish.api.Validator):
  order = pyblish.api.Validator.order + 0.1

Orderings are assumed to fall within certain ranges.

0-1: Selection (default 0)
1-2: Validation (default 1)
2-3: Extraction (default 2)
3-4: Conform (default 3)

Which means that there is no apparent way of decrementing.

import pyblish.api

class MyValidator(pyblish.api.Validator):
  """I am now indistinguishable from a Selector..."""
  order = pyblish.api.Validator.order - 0.1

So I was thinking whether it would be a good idea to slightly offset each default plug-in to lie at the center of it’s range instead of at the beginning.

0-1: Selection (default 0.5)
1-2: Validation (default 1.5)
2-3: Extraction (default 2.5)
3-4: Conform (default 3.5)

Which would make it possible to arrange a custom plug-in both before and after any defaults. Considering the otherwise large change just done with 1.1, I think the change should either happen now, or at 1.2, possibly 2.0 depending on how much it affects anyone.

I’ve done a quick test myself, and I haven’t offset any of my plug-ins further than 0.2, 0.3, which means I’m in the clear. But if you have offset it > 0.5 you will have to update your plug-in.

Thoughts?

2 Likes

I was thinking of proposing something similar myself. I have a few plugins offset by .5 I think, but that would take a minute to fix, so I’m for implementing it right away.

Great minds think alike?

An alternative came to mind, which is to make an order such as 1 the “baseline” and ranges to offset that half a step in either direction.

For example, the current test looks like this.

if 1 <= order < 2:
  return "failed validation"

But could instead look like this.

if Validator.order - 0.5 <= order < Validator.order + 0.5:
  return "failed validation"

Same outcome, but without modifying defaults, and possibly more intuitive as I’m not too fond of fractions (e.g. 1.5) for defaults. :S

Why not. Identical result. I don’t have preference so whichever seem better to you.

This works well and has been implemented in 1.1.2.

Plug-ins retain their order, and ranges now go from 1 ± 0.5. The exact mechanism can be found here and is used in the default test here.

As it’s a backwards incompatible change, ensure your plug-ins don’t offset more than 0.5 or else you might experience a change in behaviour.