# Schema, Create Folders optional folder

For episode shows, I’d like the shots to be organized like this:
/project/shots/episode/sequence/shot
For example: /project/shots/e01/sq01/0010/

And, using the same config, for non-episodic shows (defined by sequences that have no episode in the ‘episode’ field), I’d like the shots to be organized like this:
/project/shots/sequence/shot
For example: /project/shots/sq01/0010/

In templates.yml I have the following for shot root:
shot_root: shots/[{Episode}/]{Sequence}/{Shot}/{Step}/{task_name}

And I have the corresponding yml files in schema set up appropriately. Specifically, in /shots/sequence.yml
name: "[{episode.Episode.code}/]{code}"

On the network, this creates all the folders fine. But I’ve been getting this error when running “Create Folders” from the web, or when “Create Folders” is run from launching a toolkit integration:

File "C:\Users\stavernia\AppData\Roaming\Shotgun\pi\p328c47.basic.shotgun\cfg\install\core\python\tank\path_cache.py", line 1287, in _add_db_mapping if self._is_path_in_db(path, entity["type"], entity["id"], cursor): TypeError: 'NoneType' object has no attribute 'getitem'

Full error log is attached. It seems the error is happening after folders are created on disk, but before or during Filesystem Location creation. This error does not happen if I attach an episode to the sequence attached to the shot.

Any thoughts on what the issue is here?

2 Likes

Hi @stavernia,

Thanks for posting. Not sure if I could get all of details of this one, but still would like to contribute.

When “attach an episode to the sequence attached to the shot”, you are adding a custom entity to the schema, which is doable. According to the preferred way you would like to organize the shots, you are looking for a way to add a nested folder at the root. Not sure If I understand you correctly, but if so, I think the post below will give you some inspiration.

Cheers,
Ben

1 Like

Hey Ben,

Thanks for the reply. I don’t think your linked solution is the same as my issue. Episode isn’t a custom entity, it’s the default episode entity provided by Shotgun, and its functionality hasn’t been changed from default.

And the problem isn’t in the schema or schema yml files. Those work wonderfully: if episode exists in the sequence field, it adds the episode folder above the sequence folder. if episode does not exist in the sequence field, it does not add the episode folder above the sequence folder. Absolutely no problems.

The error, I believe, comes when toolkit tries to link the entities to the folders (when it tries to create Filesystem Locations). The simple fix would be to add an episode to every production, even non-episodic. The complicated fix would be to split into two toolkit configs (one for episodic, one for non-episodic). But I want to avoid either of those.

I swear this worked fine about a year ago when this was set up, but at some point perhaps it stopped working. We’ve used episodes for a while and now have a show that doesn’t have episodes. I’ll continue to debug on my end, and test some of the old configs to see if I get the same problem, but I wanted to see if anyone else has encountered this, or had a fix off the bat.

Thanks,

1 Like

This was just being discussed here as well:

Also, you can’t use the optional brackets to make schema folders optional, I think it leads to problems, and they weren’t intended to be used that way.

2 Likes