Can I setup a core hook that gets applied to all of my projects?

Since core hooks are setup differently than engine and app hooks, there's no config file that specifies where to look for them. If you're using a localized core in each pipeline configuration (the default), you can work around this challenge by using symlinks to link to a central directory that contains your core hooks.

If you're on Windows and symlinks won't work for you, you can create a python stub in your pipeline configuration(s) that adds the path of your centralized core hooks, then imports the correct one. So you'd only have to drop these stubs into your pipeline configurations once, then any updates you made to the hook(s) could be done in one place.

An example stub for the cache_location core hook is below. It also uses an environment variable to help determine where the central location for core hooks is for the studio:

#! /usr/bin/env python

"""
This is a stub to allow loading Core Hooks from a central location.

.. module:: `cache_location`
   :platform: Unix, Windows
   :synopsis: Stub to load Core Hook from central location.
"""

# IMPORT STANDARD MODULES
import os
import sys

# Add Core Hook version folder to sys path
hook_folder = r'${SOME_STUDIO_DIRECTORY}\toolkit_config\hooks\cache_location\v1.0.0'
hook_folder = os.path.expandvars(hook_folder)
sys.path.append(hook_folder)

# IMPORT YOUR STUDIO'S CORE HOOK
from cache_location import CacheLocation as BaseCacheLocation

# Needed for SGTK to work
class CacheLocation(BaseCacheLocation): pass

 

Thanks to Sebastian Kral at Pixomondo for the contribution

 

Follow

0 Comments

Please sign in to leave a comment.