We are trying to modify our configuration so that we can select which Storage Root we want to use on a per project basis. The schema can remain identical but the roots need to change. We haven’t had any luck so far.
We have attempted:
having just one storage root and overriding the value with an env var in the roots.yml. When launching DCCs however, the apps e.g. tk-maya are still initialised with the storage root as defined in the Shotgun Storages, so files are created and published to those roots.
having two storage roots, and setting the default value based on an environment variable, however this doesn’t work either as the env vars are not evaluated when this file is parsed.
having two storage roots, and using filters based on a value set in the project info, but I haven’t been able to storage roots to be filtered this way - only the schemas.
specifying the root in our templates using an environment variable, but again this isn’t evaluated, so it only seems to accept an explicit naming of the root.
Are we missing something obvious here?
I have seen this thread to which the answer is no, but I’m not sure if our case is exactly the same. We do not need the env var kept in the root for delayed evaluation. It just needs to be set at the point of checking out the project/config.
Do you need that for existing projects or for new project only? If for new, just select proper root during proejct configuration. But if you need to change existing project i think that you should modify roots.yml provide there correct id and pathes. Beside this you need to create correct shotgun storage entity (‘LocalStorage’).
Sure, you should modify root.yml file and provide there valid id and pathes just like on your Shotgun site. Look at Site Preferences → File Management, there you should have all your roots. Because hooks can ask shotgun for root path. If you have problem with getting correct shotgun_storage_id, just use python console in shotgun desktop:
Ah I see what you’re saying, but we maintain our roots.yml file in a repo that is shared across all projects. We’re trying to avoid having to maintain different branches for different projects/roots, so having a different roots.yml file per-project isn’t (currently) an option.
Hence, we were trying to have all the possible storage roots listed in the roots.yml file, then set which one is to be used through the environment or a project setting within the Shotgun db.
Well if the configuration really is per project (i.e. you never need to switch roots mid-project), then branches would be much simpler than implementing dynamic switching, so I would go with @Kemot 's suggestion.
Hello @Kemot, I am trying to find the storage id for my new local file storage, but in the shotgun desktop python console I keep getting errors saying “sg is not defined”. can you elaborate on the syntax for this call? thanks.
sg_address = https address of you SG site
script_name = name of your script (declaret on “Scripts” page)
sg_token = key of yor script (declaret on “Scripts” page)
Look at Kemot’s code more closely. It is actually querying the storage’s name, not id.
So it would be something like “primary”. The name has to match, otherwise None would be returned.
thanks, I was able to find that part out. now that I have the storage id number I have updated the roots.yml but get an error when trying to launch the project from shotgun desktop.