Schema for custom entities

Hello. Initially I send this to support, but I was advice to post here, so here we go.

Firstly, I’m using a trick @philip.scadding and others from support mentioned to hack the tank_name field in order to make some folders before the actual project name. This might or might not be related, I’m not sure. Currently my tank name is something like motion/20190101/{project_name}.

I have some templates like this:

        definition: "01_PROJECT/AE"
        definition: '@shot_work_area_aftereffects/{Project}.aep'
        definition: '@shot_work_area_aftereffects/snapshots/{name}.v{version}.{timestamp}.aep'

This is supposed to be linked to tasks linked to a custom entity, specifically CustomEntity05. But, as you can see, the template doesn’t have any mention of CustomEntity05 and that’s by design.

I created a Project entry in the templates.yml file.

I also changed the to return shot_step when using the CustomEntity05. Which I’m sure is working. Yet, when trying to save a new file, I get:

TankError: Cannot resolve template data for context 'Production, Motion Video motion_video_test_tank_hack' - this context does not have any associated folders created on disk yet and therefore no template data can be extracted. Please run the folder creation for https://XXXX and try again!
2019-09-30 10:55:36,447 [34444 ERROR] File Save - failed to generate path to save to!
Traceback (most recent call last):
  File "C:\Users\vitor.hugo\AppData\Roaming\Shotgun\bundle_cache\app_store\tk-multi-workfiles2\v0.11.11\python\tk_multi_workfiles\", line 698, in _on_save
    use_next_version, ext, require_path=True)
  File "C:\Users\vitor.hugo\AppData\Roaming\Shotgun\bundle_cache\app_store\tk-multi-workfiles2\v0.11.11\python\tk_multi_workfiles\", line 360, in _generate_path
    raise TankError("Unable to resolve template fields!  This could mean there is a mismatch "

I didn’t change anything in the schema because from what I can see there’s nothing to be changed since the shot_area template is static and the rest only has the Project key, which is included in the dictionary passed to the new_file method.



Hi Vitor

Welcome to the forums!

So from what I can tell you would like to save files into a structure that only defines a Project context. However, you would like to be able to link the files to a Task that is linked to a CustomEntity05 entity.

Unfortunately, I don’t think this is doable, the workfiles app is checking that the created folders represent the context, and in your situation there aren’t any. Your schema only goes as far as the project context, so it would be fine if you only wanted to work in the project context but since the context contains and entity and a Task as well its not able to find any folders that represent that.
I confirmed this behaviour on my side as well.

This restriction feels a little bit unnecessary to me because the Project is in the context still and you should in theory have everything you need to resolve the template. Beyond the restriction, it is good practice to include entity folders in your schema as the paths can be used to perform a reverse lookup of the context as well.

This structure however, does seem a bit odd. As you currently have it, all CustomEntity05 entities would share the same folder and would write files to the same location, so there would be no way to know which file belonged to which entity.


1 Like

Alright. It’s good to hear it’s not possible, I suspected as much.

Yes, it’s a bit weird, but it’s by design.

Thanks for the clarification, Philip.

As a side note, it would be really great if the error message was more helpful. This “mismatch schema” is thrown for pretty much everything related to templates.

Knowing what’s the issue makes the error message clear to me now. It can’t figure out the context not because there’s too few keys, but because it needs at least something to direct relate to the entity in question.

A message like “Template must contain mention of context’s entity” or something of the sort would be helpful.


I’ll bring this up with the team. I’m not sure how easy it would be.

This miss match schema error is generic, but you usually get the actual error above it. In your case the actual error with meaning was:

TankError: Cannot resolve template data for context ‘Production, Motion Video motion_video_test_tank_hack’ - this context does not have any associated folders created on disk yet and therefore no template data can be extracted. Please run the folder creation for https://XXXX and try again!

Though this error is miss leading I would say because the template doesn’t need any data extracting from disk other than a project. Perhaps this could be a bug, I’ll have to discuss it.

There isn’t a rule that the template must contain a reference to an entity, in fact our default config is setup so that in Nuke Studio you are saving the hrox file in a project context, but the difference here is that you only have Project in your context and no entity so it doesn’t complain.
It seems that if there is an entity in the context, it’s checking for folders before it even considers the template.