Single item, multiple plugins/file formats - tk-multi-publish2

Hi,

New to sgtk and shotgrid in general.

After successfully adding the camera exporter plugin to tk-multi-publish2 for Maya, I am trying to adapt it to export multiple file formats, in this case, FBX and alembic.

I have tried adding a plugin for each export/publish but tk-multi-publish2 appears to always use the second defined plugin. I assume I have missed something but can’t see what. Any thoughts would be greatly appreciated! Thank you

tk-multi-publish2.yml

  - name: Publish FBX Camera
    hook: "{config}/tk-multi-publish2/publish_file.py:{config}/tk-multi-publish2/maya/publish_camera_fbx.py"
    settings:
        Publish Template: maya_fbx_camera_publish
        Cameras: [testcam]
  - name: Publish Alembic Camera
    hook: "{config}/tk-multi-publish2/publish_file.py:{config}/tk-multi-publish2/maya/publish_camera_alembic.py"
    settings:
        Publish Template: maya_alembic_camera_publish
        Cameras: [testcam]

templates.yml

    # The location of published maya alembic cameras
    maya_alembic_camera_publish:
        definition: '@shot_root/publish/cameras/{Shot}_{task_name}_{name}.v{version}.abc'
        root_name: 'primary'
    # The location of published maya fbx cameras
    maya_fbx_camera_publish:
        definition: '@shot_root/publish/cameras/{Shot}_{task_name}_{name}.v{version}.fbx'
        root_name: 'primary'

Debug Output

I think there is a real issue with multiple plugins getting the settings from one of them.
Need to check further.

Can you test your template?
Create a dict with the fields from your context, and attempt to create a path from the template.
Can you share the publish hooks you’re referencing too?

The template appears to work, I can access it and create a path using it via sgtk.

If I create two separate items, maya.session.cameraABC and maya.session.cameraFBX, then each corresponding plugin is correctly picked up.

It looks like when using a single item (maya.session.camera) it is unable to accept multiple plugins.

Is this just not possible? Do I need an item per file format?

Yep I ran into this bug too.

I think if you change the class of your plugin it works, but not if the class is the same.
For example I had one item that needs multiple publish locations and a post_phase hook and indeed it would only keep one of the publish paths.

I hacked my way around it for now but it’s annoying.
Each Publish plugin, regardless of its class name should be an instance with its own isolated properties. It doesnt seem like that is the case.

1 Like

For me I always get tripped up by setting properties in item.properties because those are global to the collected item and can affect other plugins processing that item. You’ll want to use item.local_properties whenever possible.

For example this affects other plugins using the collected item:
item.properties["publish_template"] = publish_template

This sets it only for the current plugin processing that item:
item.local_properties["publish_template"] = publish_template

1 Like

Thats the problem,
it seems that even local properties are overriden when you use the same plugin multiple times on the same item.

As if each hook is not instantiated and isolated from itself if the class is the same.