# Publish2 customization question

**URL:** <https://community.shotgridsoftware.com/t/publish2-customization-question/8985>\
**Category:** Pipeline Integrations\
**Created:** [June 10, 2020, 7:44pm UTC](https://community.shotgridsoftware.com/t/publish2-customization-question/8985 "2020-06-10T19:44:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![deanareeno](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/deanareeno/32/796_2.png) [@deanareeno](https://community.shotgridsoftware.com/u/deanareeno)\
**Post date:** [June 10, 2020, 7:44pm UTC](https://community.shotgridsoftware.com/t/publish2-customization-question/8985/1 "2020-06-10T19:44:34Z")

</div>

Hey all,

I’m attempting to add an Asset publish item task, leveraging the out-of-the-box `publish_session_geometry.py` hook.

I created:

```
..\config\hooks\tk-maya\tk-multi-publish2\basic\publish_session_geometry_alembic.py
..\config\hooks\tk-maya\tk-multi-publish2\basic\publish_session_geometry_arnold_standin.py

```

…where the first is equivalent to `publish_session_geometry.py`, and the second is similar except the internals write out an Arnold standin rather than an Alembic, and both have class names that indicate what they do.

I’ve also modified `..\config\env\includes\settings\tk-multi-publish2.yml` in the Maya asset step section to trigger the correct hooks, and have added publish template paths for each in `..\config\core\templates.yml`.

Lastly there are some UI tweaks, screencap for clarification:

 ![custom_asset_publish](https://global.discourse-cdn.com/shotgunsoftware/original/2X/c/c6d13c47b8b7eba07e87439be5943a8c2bb42825.png)

The issue I’m running into currently, is that when I test with Validate, _both_ the **Publish Alembic** and **Publish Arnold Standin** tasks are showing that they’ll resolve the output file path and naming to be whatever is described in the `asset_arnold_standin` template publish definition, which is wrong for alembics.

From testing, it seems that whatever the order of publish plugins is in `tk-multi-publish2.yml` that resolve as a child of a given item in the UI (here **All Session Geometry** ), the one that comes last is the publish template that ends up getting used for both (e.g. if I switch it so that A follows B, the publish template for both ends up being the `asset_alembic_cache` definition from `templates.yml`, which will be wrong for Arnold standins). Also, if I eliminate one or the other, I get the desired results specific to the one that remains.

At this point, advice is appreciated.

Cheers,

-DW

---

<div class="post-metadata">

**Author:** ![philip.scadding](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/philip.scadding/32/30_2.png) [@philip.scadding](https://community.shotgridsoftware.com/u/philip.scadding)\
**Post date:** [June 15, 2020, 10:04am UTC](https://community.shotgridsoftware.com/t/publish2-customization-question/8985/3 "2020-06-15T10:04:13Z")

</div>

Hi @deanareeno

Interesting. I think we would need to see your plugins to be sure. But are you storing the `path` you want to publish on the item like we do [here](https://github.com/shotgunsoftware/tk-maya/blob/v0.10.1/hooks/tk-multi-publish2/basic/publish_session.py#L302)?

If so then both plugins will be overwriting the same setting, I think you would want to use [`local_properties`](https://developer.shotgunsoftware.com/tk-multi-publish2/api.html?highlight=properties#tk_multi_publish2.api.PublishItem.local_properties) instead so that both plugins don’t overwrite each other.

---

<div class="post-metadata">

**Author:** ![ymesh](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/ymesh/32/278_2.png) [@ymesh](https://community.shotgridsoftware.com/u/ymesh)\
**Post date:** [June 15, 2020, 5:05pm UTC](https://community.shotgridsoftware.com/t/publish2-customization-question/8985/4 "2020-06-15T17:05:18Z")

</div>

@deanareeno,  
I think you could add extra properties to your geom\_item in collector. e.g.:

```
    geom_item.properties["ass_publish_path"] = asset_arnold_standin_path
    geom_item.properties["abc_publish_path"] = asset_alembic_cache_path

```

and use these pathes in your plugin by assigning it’s value to item.properies[“path”] in Publish method.

---

<div class="post-metadata">

**Author:** ![deanareeno](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/deanareeno/32/796_2.png) [@deanareeno](https://community.shotgridsoftware.com/u/deanareeno)\
**Post date:** [June 17, 2020, 3:22pm UTC](https://community.shotgridsoftware.com/t/publish2-customization-question/8985/5 "2020-06-17T15:22:49Z")

</div>

For some yet-to-be-ascertained reason, all of the plugin items in the **All Session Geometry** stack are inheriting values on common properties based on the values of the last item through the stack, so I have been unable to use e.g. `item.properties["path"]` and the like. For the same reasons` item.local_properties` hasn’t been effective for me.

I’m not subclassing the `collector` hook at all, but what @ymesh suggested gave me an idea for a different implementation.

Now I’m creating uniquely named item properties in each of my subclassed `publish_session_geometry` hooks (e.g. `item.properties["publish_template_alembic"]` in that subclass), and when each is instanced on a Publish invocation, there’s no clashing/overwriting of values across items in the stack. In the methods of each subclass I had to change it so they’re only concerned with the keys unique to their subclass when returning values.

I also had to create relative `publish_file` hook subclasses so that their methods are also only concerned with the aforementioned unique keys/values:

```
..\config\hooks\tk-multi-publish2\publish_file_maya_alembic.py
..\config\hooks\tk-multi-publish2\publish_file_maya_ass.py

```

…and my hook definitions in `tk-multi-publish2.yml` look like e.g.:

`hook: "{self}/publish_file.py:{config}/tk-multi-publish2/publish_file_maya_alembic.py:{config}/tk-maya/tk-multi-publish2/basic/publish_session_geometry_alembic.py"`

The upshot of all this is that I’m getting expected results: creation & in-place publishes of ABC & ASS files from the correct disk loactions, validation, correct post-publish SG Publish UI button triggers, etc.

This screencap is of a successful Validate run through the SG Publish UI:

 ![custom_asset_publish_validate_working_blurred](https://global.discourse-cdn.com/shotgunsoftware/original/2X/8/88a37b1021344e97cf4c354a8523a97536fa756b.png)

Having said all of this, while it’s all “working” now, I would prefer to understand _why_ the stack items are behaving the way they are for me such that I needed to implement something that feels like a workaround rather than an “as-the-developers-intended” solution.

Cheers,

---

<div class="post-metadata">

**Author:** ![philip.scadding](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/philip.scadding/32/30_2.png) [@philip.scadding](https://community.shotgridsoftware.com/u/philip.scadding)\
**Post date:** [June 17, 2020, 3:45pm UTC](https://community.shotgridsoftware.com/t/publish2-customization-question/8985/6 "2020-06-17T15:45:24Z")

</div>

I just tried the `item.local_settings` on my side, but it’s working for me.  
I created two near identical simple plugins that both stored their paths in the accept method and then retrieved them in the publish method:  
[plugin\_two.py](https://community.shotgridsoftware.com/uploads/short-url/xRfzKlTiYtyB4Hkx7zCO47lzEOA.py) (1.2 KB) [plugin\_one.py](https://community.shotgridsoftware.com/uploads/short-url/1oozQXuhyUdragGaELzu3Lrt5WX.py) (1.2 KB)

Which resulted in the two paths being correctly logged:

 ![Shotgun__Publish](https://global.discourse-cdn.com/shotgunsoftware/original/2X/5/539b2e8289e33d3d02be6b5d0583f48cfe519abe.png)

---

<div class="post-metadata">

**Author:** ![deanareeno](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/deanareeno/32/796_2.png) [@deanareeno](https://community.shotgridsoftware.com/u/deanareeno)\
**Post date:** [June 17, 2020, 4:07pm UTC](https://community.shotgridsoftware.com/t/publish2-customization-question/8985/7 "2020-06-17T16:07:44Z")

</div>

Cool, now try subclassing the SG provided `publish_session_geometry.py` hook into 2 new hooks like I mentioned in the OP & let me know how it goes.

---

<div class="post-metadata">

**Author:** ![philip.scadding](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/philip.scadding/32/30_2.png) [@philip.scadding](https://community.shotgridsoftware.com/u/philip.scadding)\
**Post date:** [June 17, 2020, 5:07pm UTC](https://community.shotgridsoftware.com/t/publish2-customization-question/8985/8 "2020-06-17T17:07:07Z")

</div>

So that you’re leaving the template to be set in the `publish_session_geometry.py` rather than in your inherited plugins?  
I’ll have to have a look tomorrow.

---

<div class="post-metadata">

**Author:** ![philip.scadding](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/philip.scadding/32/30_2.png) [@philip.scadding](https://community.shotgridsoftware.com/u/philip.scadding)\
**Post date:** [June 18, 2020, 9:41am UTC](https://community.shotgridsoftware.com/t/publish2-customization-question/8985/9 "2020-06-18T09:41:23Z")

</div>

So I took a look at the `publish_session_geometry.py`, but I’m not sure what exactly you are overriding in your custom plugins.  
The `publish_session_geometry.py` hook is using `item.properties` rather than `item.local_properties` so if that behaviour is not being overridden then it will continue to overwrite the property for each plugin, since it will be storing it as a global value on the item rather than as a plugin specific value.

I guess ultimately it would be better if our `publish_session_geometry.py` hook used `local_properties` by default as that would mean you wouldn’t need to override that behaviour.

One slightly hacky thing you could do to avoid having to implement the full publish logic in your hook, is to override the `publish` method, set the `item.properties["publish_template"] = ...` and then call super.

I mocked up another example where both plugin [1](https://community.shotgridsoftware.com/uploads/short-url/87AwymEX6h6zXkQPkiLQjVo6yh7.py) and [2](https://community.shotgridsoftware.com/uploads/short-url/qzi266nySemcN1mOYJoEKVwHLLy.py) derive from [plugin base](https://community.shotgridsoftware.com/uploads/short-url/h3DNKHHnhui3MMJ9Zm0t7bE58rp.py).

Plugin base uses the `item.properties` like the `publish_session_geometry.py` does, but each derived plugin sets that property before calling the base method so that it is redefined for each plugin when it comes to use it.

Still the better approach would be to use `local_settings` but I appreciate that would mean taking over more of the base hook logic.

---

<div class="post-metadata">

**Author:** ![deanareeno](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/deanareeno/32/796_2.png) [@deanareeno](https://community.shotgridsoftware.com/u/deanareeno)\
**Post date:** [September 4, 2020, 6:38pm UTC](https://community.shotgridsoftware.com/t/publish2-customization-question/8985/10 "2020-09-04T18:38:55Z")

</div>

Back to put a button on this.

A couple of days after I last posted to this thread, I ended up looking at the Unreal implementation of an FBX plugin, and mimicking that process with a both an Alembic plugin and an Arnold Standin plugin, forgoing the previous work I did with `publish_session_geometry`.

It made it much easier, and the `collector`'s use clicked for me (I had initially misinterpreted its purpose, which is why I was previously avoiding it).

Looks like this, and since then I don’t use `publish_session_geometry` (or any of the aforementioned gymnastics) at all.

 ![sgpub_plugs](https://global.discourse-cdn.com/shotgunsoftware/original/2X/9/9831d1ded985f3504d37506f02f0e964b759be53.png)

Cheers,
