Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
Pyblish Search Engine

Pyblish Search

Demonstration of plug-ins for Pyblish being exposed to a search engine via customisable keywords.

How it works

Each plug-in is associated with a series of keywords, the keywords are then browsed via plain-text search.

class MyPlugin(...):
   tags = ["keyword1", "keyword2"]

The discovered plug-ins are then dynamically added to Pyblish at run-time such that publishing occurs relative to what was searched for.

For example, the search term might include "games character geometry" which would mine the collection of plug-ins available for any that matched any of the included tags, "games", "character" or "geometry".

How it is useful

Picture having access to 1500 validations, some developed by peers within your company and some provided externally through a cloud-service. You have a number of criterias that your asset must fulfill, but aren't interested in the technicalities of how to actually validate anything; you just care about what's right.

From here, you could conjure up a series of keywords relevant to your requirements and pass it off to the search engine. It would then ensure that every validation passes prior to the asset being shipped.


With this naive approach, keywords are bound to be quite specific.

For example, you might want to validate for the height of an asset. Keywords may include "<=1.5m" or ">=200m" in which case these exact keywords must exist to facilitate this exact requirement.

What would be better, is for there to be a single "MaximumHeight" validation that could be customised to whichever height was sought after.

import pyblish.api
import pyblish.util
disk = {}
class ValidateMeshDensity(pyblish.api.Validator):
tags = ["geometry", "character", "film"]
def process(self, instance):
assert True
class ValidateEntropy(pyblish.api.Validator):
tags = ["geometry", "character", "film", "game", "tv"]
def process(self, instance):
assert True
class ValidateUVOverlap(pyblish.api.Validator):
tags = ["geometry", "uv", "film", "game", "tv"]
def process(self, instance):
assert True
class ValidateDefaultPose(pyblish.api.Validator):
tags = ["rigging", "animation"]
def process(self, instance):
assert True
class CollectInstances(pyblish.api.Collector):
def process(self, context):
context.create_instance("MyInstance", family="rig")
class ExtractCharacter(pyblish.api.Extractor):
def process(self, instance):
disk["data"] = True
# Database of all available validators
validators = [
def search(queries):
"""Search engine, based on tags
queries (list): Individual tags, e.g. "film" and "games"
return list(
v for v in validators
if any(t in v.tags for t in queries)
def setup(query):
"""Register plug-ins based on search query
query (str): Space-separated search query, e.g. "film games"
validators = search(queries=query.split())
for plugin in validators + [CollectInstances, ExtractCharacter]:
setup("geometry rigging")
context = pyblish.util.publish()
for result in"results"):
if result["instance"] is None:
print("{} + {} = {success}".format(**result))
# MyInstance + ValidateUVOverlap = True
# MyInstance + ValidateMeshDensity = True
# MyInstance + ValidateEntropy = True
# MyInstance + ValidateDefaultPose = True
# MyInstance + ExtractCharacter = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment