Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Marcus Ottosson
@mottosso
True, but it wouldn't be out-of-this-world to bridge the UI; actions for example already do that
Hannes
@hannesdelbeke

if you run pyblish lite in maya, and then swap to the console and run pyblish command.
what would you expect in context.data["ui"] then?
i'm running a command, so if i ask a plugin what are you running in, it should say command.
but if i alredy ran lite, it will think i'm in lite.

bit of an edge case but worth mentioning i think

that's where the "founder" or caller could come in, who initiated the command
Roy Nieterau
@BigRoy

but if i alredy ran lite, it will think i'm in lite.
bit of an edge case but worth mentioning i think

I guess they could conflict if you'd run them exactly at the same time? But technically the UI could just "add" an extra plug-in manually to the process chain.

plugins = api.discover()
plugins += custom_plugin

Anyway, no time to fiddle with this now but there are some good ideas here! :)

Hannes
@hannesdelbeke
yes that would solve it
Marcus Ottosson
@mottosso
@hannesdelbeke Just to let you know I'm seeing your comments in issues and PRs, and will take a moment tomorrow morning to fill in with answers where I can
Hannes
@hannesdelbeke
Thanks :) . appreciate you are a very busy person and i ask a lot of questions
Michael Aldrich
@MichaelAldrich

Hi all, I noticed this today. Right now Instances are always falsey. I believe because they're based on lists, and instance.append is not something I've ever done, should I?

I saw this while going through the context.data["results"] in a unit test. This is not a major issue, but it seems like if an instance(or context) had anything in it's _data, that bool(instance) would be true. Seems like a relatively simple change to implement the __bool__ of a AbstractEntity to run bool(self._data), happy to prep an PR if that's interesting to others.

Hannes
@hannesdelbeke

how do you currently store data in your instance?

this is how I would store 3 strings in an instance

inst = context.create_instance("letters", icon="cubes", families=['string'])
inst[:] = ["a", "b", "c"]
i believe to add another you can do
inst.append("d")
Marcus Ottosson
@mottosso

if an instance(or context) had anything in it's _data, that bool(instance) would be true

Hm, is that really expected? .data is effectively metadata of the actual data, which is the contents of the Instance, which yeah is a list. At the very least, you could put any item into it, if there isn't a natural fit for what to put there. Like the nodes in a Maya scene an instance represents.

Yes, like @hannesdelbeke said. This would yield a bool(instance) of True
Although still, bool(instance) doesn't make much sense to me to begin with
In a Maya situation, where an instance represents a series of meshes, you could append those meshes - whether they are strings or PyMEL instances - such that you can iterate over those via e.g. for node in instance:
Hannes
@hannesdelbeke

it could make sense if you want to check an isntance exists, or is null

if (inst):
    inst.append("test")

expected behaviour would be bool(inst) results in true if a instance exists, ignoring any data inside the instance

Marcus Ottosson
@mottosso
it would always exist, otherwise the plug-in wouldn't get called. And if you have a context plug-in, they would either exist in that context (which is also a list) or it wouldn't. There would be no place to test for bool()
Hannes
@hannesdelbeke

yes in current setup it makes no sense,
if there is a scenario where you would want to do this. maybe make instances dynamically outside of pyblish
then the following would not be intuitive IMO

implement the bool of a AbstractEntity to run bool(self._data)

because an instance might exist, but have no data

But I think we might be steering away slightly, hopefully Michael get's back to us since I don't understand exactly what the issue is .
Michael Aldrich
@MichaelAldrich
I think the problem is that I've been using instance.data basically only, and never doing instance.append

how do you currently store data in your instance?

instance.data["chocolateData"] = ["cocoa", "milk"]
instance.data["iceData"]=["cold", "water"]

Hannes
@hannesdelbeke
turns out there is a page on the wiki for instance.append https://api.pyblish.com/pyblish.api/instance/instance.append
i've never used data myself. trying to see if the docs mention it
https://api.pyblish.com/pyblish.api/instance
this page explains the diff between the data in the list, and the metadata in data
Michael Aldrich
@MichaelAldrich
Yeah! This makes lots of sense, thanks for the help and sorry for the confusion folks :)
Marcus Ottosson
@mottosso

this page explains the diff between the data in the list, and the metadata in data

Couldn't have said it better myself :blush:

Xinjie Hu
@kosam0913
Hi guys, an quick question~ are there any specific reason that in class MetaPlugin definition, we are using init(cls, *args) instead of new?
Xinjie Hu
@kosam0913
some background story: I was trying to make some modification on the source code (hope you don't mind Marcus>:) ), so we can bind context into plugin instance itself
class MyPyblishBasePlugin(api.Plugin): 

    order = api.ValidatorOrder

    def __init__(self, instance=None, context=None):
        super().__init__(instance=instance, context=context)

    def process(self):
        print(f"current context data: {self.context.data}")
        self.context.data["global_attr"] = "test"

    def repair(self):
       print(self.context.data['global_attr'])
Marcus Ottosson
@mottosso

Hi guys, an quick question~ are there any specific reason that in class MetaPlugin definition, we are using init(cls, *args) instead of new?

I can't remember :blush: Also not quite sure what you mean by binding the context, maybe you can elaborate? What is the usecase or problem?

Xinjie Hu
@kosam0913
wah, so happy you are online! currently pyblish is using context and instance to transfer data among plugins (e.g. ValidateDIWithRepair_Current below), I was wondering if it is possible to set context or instance as plugin properties? (e.g. ValidateDIWithRepair_Lookingforward below)
class ValidateDIWithRepair_Current(pyblish.api.Plugin):

    def process(self, instance):
        assert False, "I was programmed to fail, for repair"

    def repair(self, instance):
        self.log.info("Repairing %s" % instance.data("name"))


class ValidateDIWithRepair_Lookingforward(pyblish.api.Plugin):

    def process(self):
        print(f"current context data: {self.context.data}")
        print(f"current instance data: {self.instance.data}")

    def repair(self):
       self.log.info("Repairing %s" % self.instance.data("name"))
Xinjie Hu
@kosam0913

then when I read the source code, I found out that before the actual plugin is instantiated during pyblish, following code will be executed:

class MetaPlugin(type):

    def __init__(cls, *args, **kwargs):

        # cls.__pre11__ = False
        # evaluate_pre11(cls)
        evaluate_enabledness(cls)

        # Compute once
        cls._id = str(uuid.uuid4())
        cls.id = lib.classproperty(lambda self: self._id)

        # may I add set some custom atttribute here?

        return super(MetaPlugin, cls).__init__(*args, **kwargs)

hence I was about to ask 1. are there any concerns that we are using init() not new() here? 2. generally is it possible to set context/instance as an attribute of plugin? 3. or maybe I can add customize attribute for our own purpose? ( hope I state myself clearly, and pardon me if I make any confusion

Marcus Ottosson
@mottosso

What is the different to accessing context as an argument versus a member attribute? :O

# Current
print(context.data)

# Proposed
print(self.context.data)

I'm not seeing the advantage

Xinjie Hu
@kosam0913
I agree with you :< (whispering), but we were trying to see if we could potentially wrap it more 'developer friendly'. so developers can just care about the plugin object itself when they are developing and no need to put any other arguments.
Marcus Ottosson
@mottosso
Ah, then no I can't remember any specific reason. Give it a try!
Xinjie Hu
@kosam0913
Okie! thanks for your time. honestly I've been doing some 'experiments' around, and found everything is such well-designed so it is not that easy to modify without mess it up(at least for me), haiyaya.
Marcus Ottosson
@mottosso
Heheh, well if you do manage to improve upon it, pull-requests are still open
Xinjie Hu
@kosam0913
roger that, let me try >:D
Michael Aldrich
@MichaelAldrich
Has anyone seen the case where Exact does not work as a matching algorithm? Here's the code I'm testing with:
from pyblish import api
import pyblish_lite

class FakeCollector(api.ContextPlugin):
    order = api.CollectorOrder
    def process(self, context):
        context.create_instance("foo_single", family="boo")
        context.create_instance("foo_multi", families=["boo"])

class FakeContextValidator(api.ContextPlugin):
    order = api.ValidatorOrder
    label = "Fake context validator"
    def process(self, context):
        from pyblish import logic
        self.log.info(str(logic.instances_by_plugin(context, FakeInstanceValidator)))


class FakeInstanceValidator(api.InstancePlugin):
    order = api.ValidatorOrder
    families = ["boo"]
    match = api.Exact
    label = "Fake Instance validator"
    def process(self, instance):
        self.log.info(instance.data["label"])
        self.log.info(str(instance.data.get("families")))
        self.log.info(str(instance.data.get("family")))

pyblish_lite.show()
image.png
Which is giving me this result, as you can see my instance validator never runs
Michael Aldrich
@MichaelAldrich
for completeness, this doesn't seem unique to pyblish lite, if I use pyblish.util.publish() and inspect the context.data["results"] I also see that the instance validator is never run.
Marcus Ottosson
@mottosso
Hm, looking at the algorithm itself: https://github.com/pyblish/pyblish-base/blob/master/pyblish/logic.py#L23 it does look like it should match? I wonder whether it's got to do with any default family in there. Which families are being printed?
Michael Aldrich
@MichaelAldrich
I am shame. With the clarity of a night of sleep I realized this was a mistake with targets, which do not seem to affect the collector or context plugin, but do affect the instance plugin.
Michael Aldrich
@MichaelAldrich
Aha! I found it! The targets also obey the match algorithm. That was my missing piece. I don't see that mentioned in the docs.
Nik Shankar-Noble
@nikshankarnoble
Hi all! :) I'm trying to familiarise myself with Pyblish at the moment and was interested in some of the Intermediate topics listed at https://learn.pyblish.com/#content but I've been getting a 502 error when trying to access the forum over the last two days. Does anyone here know if that information is available elsewhere?
Marcus Ottosson
@mottosso
Oh no, investigating the forum now. Thanks for letting me know
Nik Shankar-Noble
@nikshankarnoble
Thank you so much! :) Very much appreciated
Marcus Ottosson
@mottosso
It's back up
Nik Shankar-Noble
@nikshankarnoble
Thank you!!
Marcus Ottosson
@mottosso
Aaaaand it's down again :blush: Looks like the machine is out of disk space, working on a fix now.
Marcus Ottosson
@mottosso
Allright, here's to the next 7 years of uptime :beers: