When exactly core hooks are called

Core hooks are powerful and there are some docs around them, but I often find myself asking, “When exactly is this called?” and I have to do a lot of experimenting to figure out the best core hook to override to do what I need.

Specifically, I’m wondering about the following:

The main question I have is around more of the start-up and launching workflow. Specifically these:

  • bootstrap.py
  • bundle_init.py
  • tank_init.py
  • pipeline_configuration_init.py
  • pick_environment.py

So in general, yes I know when they are fired. But I’m less sure when they’re called in relation to the overall bootstrap process. It would be great to have a bit more of a specific timeline, diagraming when each of these is called in relation to the artist workflow in SG Desktop or the Shotgun engine. I’m typically trying to setup something or ensure an env var is set so I can act on it before artists launch into their DCC or custom TK app. Maybe there are other core hooks that get run between SG Desktop login and loading the PC for their project? I don’t know.

Also important to highlight is when they are called multiple times in the workflow of an artist logging in to SG Desktop and then clicking on their Project.

Finally, how this may differ if an artist is launching from Shotgun or the shell, or if there are similar workflows that may NOT fire the core hook, that we should watch out for.

cheers,
kp

6 Likes

I think this is a great question, but it will take a little to put something suitable together.
We’ll have to do a bit of digging and get back to you.

2 Likes

Fair enough… perhaps in the meantime I could put forth my hypothetical situation that brought on this question?

We have 2 different types of projects at a studio. Both use the same exact config. The only difference between the two is the templates. Ideally it’d be nice to not have to manage 2 separate configs for this (especially since the templates also overlap about 95%). So I have been experimenting with using an environment variable to designate what template should be used.

I’m currently using the bootstrap.py core hook that looks at the “Type” field on the SG Project for the current pipeline config and sets the env variable. Then I have a single template file core/templates.yml that includes another template file based on that environment variable.

include: 'templates/templates-$TK_PROJECT_TYPE.yml'

This works well at first when you load things up in SG Desktop :smile:, but then if you click out of the Project and back in, it fails to set the env variable :frowning_face:. So I don’t have the right place for this logic. It also seems to fail in the Shotgun engine in some cases.

So… where would the right place for this logic be where I know my pipeline config but before anything has actually be initialized/verified? And how can I ensure it will be run every time?’’

Wondering if anyone else has done this as well?

3 Likes

Hey KP – This isn’t a full answer to the question of when does each core hook run in the initialization process, but take a look at this post:

I think what you might be after is pipeline_configuration_init.

I’m not sure exactly where in the process bootstrap.py runs – I’ll run that by the team and see if we can get something definitive.

3 Likes