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

Plugin active state by conditions #341

Open
nasefbasdf opened this issue Apr 17, 2019 · 7 comments
Open

Plugin active state by conditions #341

nasefbasdf opened this issue Apr 17, 2019 · 7 comments

Comments

@nasefbasdf
Copy link

There are plugins which we would like to completely skip in some cases. The active class property would appear to be just what we need but I cannot find a way to use it.

There could be several cases where a plugin should be skipped, but consider the following simple example:

  • The artist is publishing a new version of their work.
  • There are some options they can choose from on a custom UI before the pyblish process is started.
  • Depending on those options a pyblish plugin should be considered not active.

Alternatively we could implement the logic for skipping the work inside the plugin, but then it would still appear on the UI for example in pyblish-qml.

Generally speaking I cannot imagine any way to properly take advantage of the active property on the plugins. They are either True or False forever, since there is no API apparently to set/override them at runtime.

Ideally (or so I think) I would like to have an early collector that deactivates some integrators for example.

@darkvertex
Copy link
Contributor

Theoretically you could use Pyblish "targets" for this:
https://api.pyblish.com/pages/targets.html

...but what I'm not sure is if modifying them mid-execution at say the Validation stage, if it's even acknowledged properly by the UI. I've never tried modifying them during execution, only prior to it.

@mottosso
Copy link
Member

I can think of 3 options.

  1. Have a look at instance.data["publish"] = False. Was going to include a reference to some documentation, but there doesn't seem to be much of it, sorry about that.
  2. You can also assign/unassign families to instances at run-time; if your plug-in doesn't have an instance with a matching family, it'll get skipped. A post-collector Context plug-in might be a good fit for that.
  3. Other than that, you can assign an expression to active = True of plug-ins.
class MyPlugin(...):
  active = my_pipeline.some_condition()

But editing a plug-in whilst it's running is a little too meta I think, and I can't think of any way that could work; though if you do then a PR is welcome.

@nasefbasdf
Copy link
Author

Thanks for the suggestions. I'll think a little what targets or families modifications could achieve. I'm aware of instance.data["publish"] which is not what I'm looking for. The 3rd option could work... not sure why I've not thought of that. I'll try some things out.

For a better understanding of the motivation behind this, I have a more concrete example this time:

  • There is a pyblish plugin that controls incrementing the version of a work.
  • The artist sometimes may want to not increment the version of the work, just export/publish it. (When a work encompasses multiple apps (maya+houdini, etc.), they need to publish from all of them while only bumping the version at the last one).
  • The plugin was named "Version up". This created a little confusion. If they chose not to bump version the plugin was still visible on the UI. (with a checked checkbox next to it initially and it "ran" just like the others at publish)
  • For now as a workaround I've renamed the plugin to "Version control". So it is not that alarming to the artist.

@mottosso
Copy link
Member

mottosso commented Apr 18, 2019

with a checked checkbox next to it initially and it "ran" just like the others at publish

This sounds like a bug; an unchecked plug-in shouldn't run at all, can you confirm? Preferably with a video/gif if possible.

With option 3, one key thing to keep in mind, that differs from standard Python modules, is that your plug-in is being reloaded on every reset. So that expression is quite dynamic.

@darkvertex
Copy link
Contributor

There is a pyblish plugin that controls incrementing the version of a work.
The artist sometimes may want to not increment the version of the work, just export/publish it. (When a work encompasses multiple apps (maya+houdini, etc.), they need to publish from all of them while only bumping the version at the last one).

I've sometimes created "option instances", that is, an instance that represents a boolean yes/no setting, and then I use that instance with one or more instance plugins related to its family to process the optional feature or not.

In pyblish-qml, when you create instances, you can set instance.data["category"] = "Section:" to label the section in the UI they are in. There's a screenshot of what that looks like in the PR that implemented it: pyblish/pyblish-qml#303

You can use the category to add a few checkbox "options" below the instances to be published.

@davidlatwe
Copy link
Contributor

I've sometimes created "option instances", that is, an instance that represents a boolean yes/no setting, and then I use that instance with one or more instance plugins related to its family to process the optional feature or not.

That's genius !

@mottosso
Copy link
Member

Haha, that's great. :)

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

No branches or pull requests

4 participants