Choosing plugins when using pyblish from command line


#1

Hello,

I wish to use Pyblish from the command line and I wonder if it is possible to define which plugins will be used for a specific type of input. For instance, at the moment, when publishing a single file to Ftrack, pyblish will try to run all collectors in my config folder whereas I’d like to only run a single family of collectors.

I am running the publication with the following (using pyblish-base: 1.4.2):
$ pyblish -d current_file /path/to/myfile.tif publish

I tried to set other data attributes like “family” but without success.
As a next step, I’d like to use pyblish-lite outside any app for ingesting non app related files… I can’t find how to send a specific input to pyblish-lite and select which plugins should be loaded.

Is this not at all the way to go with pyblish ?
Should I make my own specialised CLI wrapper and set custom host, family from there ?
Best,

Jerome


#2

Hey @samson-jerome,

Have a look at the command line options for Pyblish, there’s one in particular you might find helpful with this; --plugin-path. It’ll take the path to a directory in which to look for plug-ins.

$ python -m pyblish --help
Usage: pyblish [OPTIONS] COMMAND [ARGS]...

  Pyblish command-line interface

  Use the appropriate sub-command to initiate a publish.

  Use the --help flag of each subcommand to learn more about what it can do.

  Usage:
      $ pyblish publish --help
      $ pyblish test --help

Options:
  --verbose                       Display detailed information. Useful for
                                  debugging purposes.
  --version                       Print the current version of Pyblish
  --paths                         List all available paths
  --plugins                       List all available plugins
  --registered-paths              Print only registered-paths
  --environment-paths             Print only paths added via environment
  -pp, --plugin-path TEXT         Replace all normally discovered paths with
                                  this This may be called multiple times.
  -ap, --add-plugin-path TEXT     Append to normally discovered paths.
  -d, --data TEXT...              Initialise context with data. This takes two
                                  arguments, key and value.
  -ll, --logging-level [debug|info|warning|critical|error]
                                  Specify with which level to produce logging
                                  messages. A value lower than the default
                                  "warning" will produce more messages. This
                                  can be useful for debugging.
  --help                          Show this message and exit.

Commands:
  gui
  publish  Publish instances of path.

$

#3

Thanks for the answer, I think we have had a rather dry organisation of our plugins, they’re currently all in a single folder for a specific project.
I’ll reorganise all this and let env (or pluginpath option) define which plugin to call in specific context.
Thanks,


#4

That’s one option. Another option is organising plug-ins by which family they apply to.

For example, if 5 of them apply to myFamily, then if this instance is collected via the command-line, then only those plug-ins would run.

You could, for example, have one directory with only plug-ins related to collecting from the command-line, such as image sequences or .obj files, and append this to your normal PYBLISHPLUGINPATH when running from the command-line. This collector could be responsible for assigning an appropriate family to the collected instance, such that the plug-ins you want to have run on it are discovered and run.

Also don’t forget you can explicitly create/call plug-ins with a minor Python script.

quick_publish1.py

from pyblish import util

class Plugin1(...):
  pass

class Plugin2(...):
  pass

util.publish(plugins=[Plugin1, Plugin2])

Or…

quick_publish2.py

from pyblish import api, util

all_plugins = api.discover()
relevant_plugins = list(plugin for plugin in all_plugins if "thisFamily" in plugin.families)
util.publish(plugins=relevant_plugins)

Hope it helps!


#5

Hi Marcus,
Both workarounds are both interesting, I’ll filter the plugins by families like in your second example for the moment as it seems clearer.

Thanks again for your time and the quick answers !