Check plugins order


I have a function that receives the plugin and instance back from a callback. I want to check if my instance just ran in a validation plugin.

I looked at the api and there doesn’t seem to be any mention of a convenience function for this. Though I know internally pyblish uses lib.inrange(number,base,offset=0.5).

Since this is not mentioned in the api I take it to be private to the package.

Could I request either we make this public, perhaps accessible through the utils module?
or add something like:

def get_cevi_order(order):
    return next((aOrder for aOrder in [api.CollectorOrder,
                                       api.IntegratorOrder] if lib.inrange(aOrder, order)),None)

which would then be used something like:

if pyblish.api.ValidatorOrder == pyblish.util.get_cevi_order(plugin.order):
    #do stuff

perhaps that over complicating things and I could simply use

if pyblish.api.ValidatorOrder == round(plugin.order):
    #do stuff

Thanks @Philip_Scadding.

Exposing or adding new functionality to the API means we’ll have to support this exact behavior forever and ever and include backwards compatibility fixes for it when/if it ever should change, so it’s very very important that we are 100% sure that it is absolutely necessary to do so.

You are right that this is the function that it is using internally and that it is private to the library.

I get that you need it for the specific thing you are currently implementing, but what I would suggest is that you keep using lib.inrange until you are either more confident that it is the way to go or until you find additional, but unrelated, use for the feature.

If you can provide minimal, but complete, examples (plural) then that would also really help speed this process up and make things the most clear for everyone.

Yeah I think I’ll probably just use the rounding up of plugin order and compare it to one of the predefined orders within my code, works fine for my situation, and I’d rather not access something that is designed to be private. There’s probably no need for making lib.range public, certainly I couldn’t see it getting a great deal of use.

Out of curiosity though, just from the point of view of the library structure and whats public and whats not. Would you have made pyblish.lib.inrange public or would you have put a wrapping function in utils?

If you take a peek in, you’ll see how it “forwards” members of internal modules, including some from I think spontaneously this is how I would have exposed it, possibly under a new name as you have given it. I’m not sure, it would have to depend on the use cases.