Incomplete context from path

Hi,

In my templates I have this template :

3d_asset_root: assets/{sg_asset_type}/{Asset}/{Step}
maya_asset_publish:
    definition: '@3d_asset_root/publish/{Asset}_{Step}[_{name}]_v{version}.{maya_extension}'
    root_name: primary

If I do :

path = r'\\server01\shared2\projects\Donat_test123_P42918\assets\Prop\bidule01\Render\publish\bidule01_Render_v007.ma'
tk = sgtk.sgtk_from_path(path)
ctx = tk.context_from_path(path)

I get a context containing information about the entity (name, id, type)

2/ The problem

In my templates I also have :

render_asset_output : images/renders_assets/{Asset}
maya_asset_render_output:
    definition: '@render_asset_output/arnoldRender/{Asset}_{Step}[_{name}]_v{version}[/{RenderLayer}][/{AOV}]/{Asset}_{Step}[_{name}]_v{version}.{SEQ}.exr'
    root_name: primary

In this case, if I do:

path = r"\\server01\shared2\projects\Donat_test123_P42918\images\renders_assets\bidule01\arnoldRender\bidule01_Render_v009\masterLayer\bidule01_Render_v009.%04d.exr"
tk = sgtk.sgtk_from_path(path)
ctx = tk.context_from_path(path)

There’s no entity in the context (i.e. ‘entity’: None)
I don’t understand why there’s no entity, as compared to the working example. I looked the doc but didn’t find an answer. Sorry if this is obvious.

Regards

4 Likes

Hi @donat

So it shouldn’t have anything to do with the templates, the context_from_path doesn’t consider them. It’s based purely on the schema and the registered folders in the path cache.

I just tested here having the same Asset registered in two different locations and then trying to extract the context from both paths, and it worked for me.

So I wonder if there is something up with your registered paths. First I would make sure you run synchronize_filesystem_structure() before you attempt to call this, to make sure that the local path cache is in sync.

If that doesn’t work then we’ll need to take a look at your path cache/schema to try and figure whats going on.

Cheers
Phil

3 Likes

Hi,

Thanks Philip.
Indeed I tested this with the synchronize_filesytem_structure(); like this :

tk = sgtk.sgtk_from_path(path)
tk.synchronize_filesystem_structure()
ctx = tk.context_from_path(path)

And got the same result, no entity found. I’m going to look into my schema, thanks for pointing it out. I suspect it comes from an error there.
Btw, what’s the ‘path cache’ ? I understand ‘schema’ as the folder structure residing in config/core/schema, but I’m not sure to understand what you mean by ‘path cache’.

BTW, is there documentation about the way the context is built when using the context_from_path ? I searched but did not find information about this specifically.

Thanks

Donat

4 Likes

We have a little bit of documentation on the path cache, but perhaps not enough to help explain what is going on here.

Essentially the context_from_path method is looking up the path you provided in the path cache, which is a registry of path to entity associations. So if the path can’t be found/matched to entities in the path cache, then no context can be derived.

What you can check is that when you create the folders for your asset, that you get the appropriate FilesystemLocation entities created in Shotgun, ie each entity folder that should have been created in the schema gets an entity. Also list type folders are a bit special so they won’t be associated with an entity, but your Asset folder should.

5 Likes

Thanks Philip,

I corrected the schema and that solved it.

Regards

3 Likes