Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't order Collectors negatively #210

Closed
mottosso opened this issue Jul 16, 2015 · 6 comments
Closed

Can't order Collectors negatively #210

mottosso opened this issue Jul 16, 2015 · 6 comments
Labels

Comments

@mottosso
Copy link
Member

Investigate this.

@mottosso mottosso added the bug label Jul 16, 2015
mottosso added a commit to mottosso/pyblish-base that referenced this issue Jul 18, 2015
@mottosso
Copy link
Member Author

Hey @tokejepsen, I can't reproduce this, it works fine here.

Could you try this?

import pyblish.api

count = {"#": 0}

class MyCollector(pyblish.api.Collector):
    order = pyblish.api.Collector.order - 0.49

    def process(self):
        count["#"] += 1

pyblish.api.register_plugin(MyCollector)

import pyblish.util
pyblish.util.publish()

assert count["#"] == 1

@tokejepsen
Copy link
Member

I get this error in the Hiero integration, when I try to inject some data into the context;

import pyblish.api

import hiero


@pyblish.api.log
class SelectProject(pyblish.api.Selector):
    """Inject the active project into context"""

    version = (0, 1, 0)

    def process(self, context):

        context.set_data('activeProject', value=hiero.activeProject)

If I renamed the plugin to SelectActiveProject it gets evaluated first, but can't rely on that (?). When I have a negative order like order = pyblish.api.Collector.order - 0.49, the plugin gets ignored by Pyblish.

@tokejepsen
Copy link
Member

I tried pyblish.util.publish(), and that works, so it seems to be something with pyblish ui?

@mottosso
Copy link
Member Author

It's not very obvious at the moment, but you can't store anything but plain-old-data (POD) as data in the context or instances; that is, nothing that isn't JSON serialisable.

As a test, you can ensure that whatever you store doesn't throw an exception when you pass it to json.dumps, and in general it includes any regular Python datatype, like dicts, lists, strings, ints etc.

If you need to store custom classes, you will need to implement a serialisation method on them and generally a deserialisation equivalent also, but its simpler to stick with the basics types, a.k.a. plain-old-data.

Was this what caused the problem? In that case, the negative order shouldn't have any effect, could you confirm?

@tokejepsen
Copy link
Member

I tried with just passing a plain string, and still got the problem. Can replicate in Maya with this plugin;

import pyblish.api


@pyblish.api.log
class SelectActiveProject(pyblish.api.Selector):
    """"""

    order = pyblish.api.Collector.order - 0.1

    def process(self, context):

        context.set_data('activeProject', value='something')

Initially the plugin doesn't show in the pyblish ui terminal, but if you comment out the order attribute of the plugin, it appears in the terminal.

@mottosso
Copy link
Member Author

mottosso commented Aug 1, 2015

Ok, I can replicate this. Will investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants