Templates.yml lowercase sg_asset_type

I would like to be able to lowercase the list items in Asset.sg_asset_type from within the templates.yml of the pipeline config. I was looking at the post using the core/hook/example_hook_template.py but I don’t think this works with templates.yml.
Reference to example_hook_template:

I tried using this example_hook_template hook in template.yml with no luck. I tried it as a key, string, and path. I might be applying this incorrectly to utilize the hook.
templates.yml snippet:

        type: str
        shotgun_entity_type: Asset
        shotgun_field_name: sg_asset_type
    asset_type_lower: hook:example_hook_template:{sg_asset_type}

example_hook_template.py snippet:

class ExampleTemplateHook(Hook):
    def execute(self, setting, bundle_obj, extra_params, **kwargs):
        template_name = extra_params[0].lower()

My backup option would be to utilize the hooks to override the folder creation, publishing, workfiles, and so on to insert code to lowercase any use of sg_asset_type. If I go this route, I feel I have to do this too many hooks.



Hi Mark,

I didn’t try this myself, but I think it may be possible to do something like the following:

Assuming, that sg_asset_type is a List field that contains a managable amount of fixed strings. You could define the key in your templates as:

        type: str
            CHAR: char
            VEH: veh
        shotgun_entity_type: Asset
        shotgun_field_name: sg_asset_type

choices – List of possible values for this key. Can be either a list or a dictionary of choice:label pairs.


Maybe worth giving this a go.



Hey @mdthielen I’ve used the process_folder_name.py hook for this in the past to force filesystem folder names to conform to lowercase.

This allows you to then also call sgtk.util.shotgun_entity.sg_entity_to_string in code to run the hook outside of folder creation for a specific entity, entity type or field.