Loading hooks outside of the config in project yaml configurations?

I tried putting a full path to a python file in the yaml but it doesn’t seem to want to work, can we load python files from outside the config?

i.e.:

# shot step
settings.tk-multi-publish2.nuke.shot_step:
  collector: "{self}/collector.py:g:/projects/pipeline/nuke/tk-multi-publish2/tk-nuke/basic/collector.py"

(tried multiple variations of paths, including unc)

2 Likes

Hi Ricardo – I tried this out and got some unexpected behavior.

In my test, I had the following line for the standalone Publisher:

collector: "/Users/sassoot/temp/collector.py"

Which gave me the following error:

2020-01-06 22:03:39,569 [67208 ERROR sgtk.env.project.tk-desktop] App 
configuration Error for tk-multi-publish2 (configured in environment 
'/sgtk/software/shotgun/goats/config/env/project.yml'). It will not be 
loaded: Invalid configuration setting 'collector' for tk-multi-publish2: The 
specified hook file '/Users/sassoot/temp/collector.py.py' does not exist.

It’s trying to add .py to the end of whatever’s specified. So, I tried

collector: "/Users/sassoot/temp/collector"

and that worked.

So, that’s a semi-decent workaround, but:

  • Does that actually work for you?
  • While we have a bunch of different formats for specifying hooks, using an absolute path is not a documented one. If we do support it, we should document it. And I don’t see why we wouldn’t support it, though I’d have to go back to the team to learn more about the why – there may be some history there.
  • All the other formats allow a full file path. To me it feels like a bug that this balks in this way – it’s rather unintuitive that you can’t just paste in the full path and expect it to work.

So… let me know if that works for you (and if not, let me know if you’re getting some other error in tk-<ENGINE>.log from the appropriate directory for your operating system, and we’ll go from there.

2 Likes

Also Ricardo, just a quick heads-up that I changed the subject of your post to reflect that the notation we’re talking about here is around hooks, not arbitrary python files in the environment config files.

2 Likes

Hmm, actually, I didnt know you could specify it from an environement variable, that opens up some functionality for us! So that may work :slight_smile:

1 Like

Oh, great! Lots of good gems in our documentation, sometimes a little harder to find than you’d hope. I’m working on a guide to taking over hooks; I’ll be sure this is all laid out there.

If environment variable is a good solution for you, I won’t go to the team with this one just yet. If you do end up wanting to go the absolute path route, I’ll dig deeper into it.

I think env variables would be what we would use more than hardcoded paths so that should be fine :slight_smile:

1 Like