Pyblish By Example
1.8
1.8
  • Introduction
  • Hello World
  • Quickstart
  • Files
  • Coordination
  • Architecture
  • Branching I
  • Branching II
  • Branching III
  • Sharing
  • Validating I
  • Validating II
  • CVEI I
  • CVEI II
  • CVEI III
  • CVEI IV
  • Data
  • Report I
  • Report II
  • Report III
  • Report IV
  • Report V
  • Callback I
  • Callback II
  • Callback III
  • Logging
  • Filtering
  • Next Steps
Powered by GitBook
On this page

Was this helpful?

Validating II

In the previous example, we ensured that instances are title-cased. But failure doesn't stop subsequent plug-ins from actually writing to disk.

import pyblish.api

disk = {}
items = ["JOHN.person", "door.prop"]

class CollectInstances(pyblish.api.ContextPlugin):
  order = 0

  def process(self, context):
    for item in items:
      name, suffix = item.split(".")
      context.create_instance(name, family=suffix)

class ValidateNamingConvention(pyblish.api.InstancePlugin):
  order = 1

  def process(self, instance):
    name = instance.data["name"]
    assert name == name.title(), "Sorry, %s should have been %s" % (
      name, name.title())

class ExtractInstances(pyblish.api.InstancePlugin):
  order = 2

  def process(self, instance):
    disk[instance.data["name"]] = instance

pyblish.api.register_plugin(CollectInstances)
pyblish.api.register_plugin(ValidateNamingConvention)
pyblish.api.register_plugin(ExtractInstances)

import pyblish.util
pyblish.util.publish()
print("JOHN" in disk)
# True

To remedy this, we'll turn our attention to some of the pre-defined orders provided by Pyblish.

  • Collection

  • Validation

  • Extraction

  • Integration

Collection sets the stage for validation. Once validation is complete, Pyblish takes a moment to consider whether any of the plug-ins that ran threw an error. If it did, it stops processing and returns control to the user.

In the next example, we will dig deeper into this mechanism and find out more about what it can do for us.

PreviousValidating INextCVEI I

Last updated 5 years ago

Was this helpful?

This behavior is paramount to publishing. If you think back to earlies in this guide, you may remember the following visualisation of it.

image
Quickstart