Publish hook settings

Hello everyone.

I’m currently trying to implement a collector hook for tk-multi-publish2.
The documentation says that we can use a “hook” type parameter in the settings of collector hook.
However, I don’t know how to set up a “hook” type parameter and what using it will allow me to do.

Does anyone know how to use it?

You need to point the publisher to the hook path. Depending on your configuration these settings might be located in different places, mine is in env/shot_step.yml:

      tk-multi-publish2:
        location: '@apps.tk-multi-publish2.location'
        collector: '{self}/collector.py:{engine}/tk-multi-publish2/basic/collector.py'
        collector_settings:
          Work Template: blender_shot_work
          Publish Template: blender_shot_publish
          Alembic Template: cache_alembic_publish
        publish_plugins:
        - name: Publish Scene
          hook: '{self}/publish_file.py:{engine}/tk-multi-publish2/basic/publish_session.py'
          settings:
            Work Template: blender_shot_work
            Publish Template: blender_shot_publish
        - name: Publish Geometry
          hook: '{self}/publish_file.py:{engine}/tk-multi-publish2/basic/publish_session_geometry.py:{config}/tk-blender/publish_geometry.py'
          settings:
            Work Template: blender_shot_work
            Publish Template: cache_alembic_publish

A few things to note:
{config} refers to your config directory config/hooks/
{self} refers to the app’s hooks directory: tk-multi-publish2/hooks/
{engine} refers to the engine’s hooks directory

You can add your arbitrary settings under collector_settings, which the collector hook will know how to use.

Thanks for the reply.

I’m sorry for the misunderstanding.
What I don’t understand is the meaning of

" This should correspond to one of the data types that toolkit accepts for app and engine settings such as hook , template , string , etc."

in the “settings” section of this page.

So, you can configure another hook in the hook’s own settings. But if you don’t know what to do with it, is it just out of curiosity that you ask?
Haven’t used such a setting, but I’m guessing you can reference other hooks, which you run from inside the collector. There is probably some nicer syntax for calling them, provided by the settings system. Same goes for template settings - if you define a setting as template you can obtain the actual template easily.

I think it would be useful to be able to add other hooks in the hook, so I’d like to try it, but I’m having trouble understanding how to use it at all.

Hey @ito

TLDR: This is a WIP feature

From my reading of the docs and reading the code in mp2 it sounds like the settings defined in a collector hook have an expected schema. type is simply one of the expected keys in a specific setting definition. Collector settings from a configuration are then just dictionaries that end up being used to instance a PluginSetting instance. The value of type is completely arbitrary and then something that each collector hook would have to validate or make use of to help interpret the value of the setting.

Specifying type: "hook" or otherwise does not actually do anything to transform or validate the value provided, it’s just a suggestion that would have to then be handled within the collector and as @mmoshev suggests there may be some api methods in future to easily perform these validations or transformations but I can’t see anything currently available. The example publish_file.py hook implements a design pattern where methods pass the settings and an item which then may or may not be used. You can see in the definition of get_publish_type(self, settings, item) it makes use of the "File Type" setting but simply calls the value attribute on the PluginSetting instance that is returned. This value is assumed to be a list, and the actual value is either something provided in a configuration or the default value defined in the collector.

Worth a PR to implement this behaviour I think!

2 Likes