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

Setup and Teardown plug-ins #352

Open
mottosso opened this issue Sep 19, 2019 · 3 comments
Open

Setup and Teardown plug-ins #352

mottosso opened this issue Sep 19, 2019 · 3 comments

Comments

@mottosso
Copy link
Member

Goal

Enable preparation and handling of the initial and final stages of the publishing pipeline.

Motivation

At the moment, if processing fails in response to a failed test, there's little you can do. If system-wide state was changed during processing - such as files having been extracted, database written to - you aren't given a change to clean things up.

To balance this "teardown" process, we'll also have a "setup" that runs first, regardless of plug-in order. To setup database connections and other things relevant to the whole test, and later torn down in the tearndown plug-in.

Implemenation

from pyblish import api

class MySetup(api.ContextPlugin):
  ...

class MyTeardown(api.ContextPlugin):
  def process(self, context):
    if any(r["error"] for r in context.data["results"]):
      # do cleanup

api.register_setup_plugin(MySetup)
api.register_setup_teardown(MyTeardown)
@tokejepsen
Copy link
Member

api.register_setup_teardown(MyTeardown)

Would this be better with api.register_teardown_plugin(MyTeardown) ?

@mottosso
Copy link
Member Author

Oh, yes, you're right. Typo.

@davidlatwe
Copy link
Contributor

davidlatwe commented Sep 27, 2019

Instead of registering as teardown plugins, what about adding an attribute teardown ?

class MyTeardown(api.ContextPlugin):
    teardown = True

And these kind of plugins will also guaranty to run even user pressed the GUI Stop button.
☝️ This is something I might need for pyblish_qml.

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

No branches or pull requests

3 participants