Tk-multi-workfiles2 not detecting other user's files

Hey!

I think I found a bug in the WorkArea._resolve_user_sandboxes code.

What is Happening (Bug #1)
The code is fast exiting before it determines my “Sandboxes”.
This is happening because _resolve_user_sandboxes states that it requires all non-optional keys with the exception of user keys. see here

This means that because my template is missing keys like “version” or “extension” it decides to not even try looking for paths.

In an example template like this:
sequences/{Sequence}/{Shot}/script/nuke/{Shot}{Step}[{output}][{name}]v{version}.{HumanUser}.{extension}

There are required keys {version} and {extension} that cause it to exit before calling sgtk.paths_from_template for my template.

Now maybe there is some arcane knowledge as to why we don’t want that. But from what I can tell, paths_from_template supports globbing the missing keys even if they are required.

That brings me to another bug that I think is in the code.

Bug #2
Assuming the code actually gets to our paths_from_template call, the skip_keys arg is being passed incorrectly. paths_from_template states that skip_keys requires a list not a set. It is directly calling append on that if there are missing required keys. Now because of bug#1 we don’t have any, but that’s not a good enough reason.

This means that even if I patch the code so that it will continue until the paths_from_template call, it errors because you can’t append to a set.

Now, lets assume we cast our user_keys to a list so that it is passed correctly.
The globs it’s building me still are wrong.

I get back globs like this
/mnt/Projects/myproj/sequences/seq001/shot001/script/nuke/shot001_comp_v*..

Which works, except what if all of my paths use the optional keys {name} or {output}. Bummer eh?

Bug #3
paths_from_template supports an argument called skip_missing_optional_keys which we can pass as True that will build globs supporting our optional keys too
see here.

I can submit PRs for this, but I wanted to get some thoughts from the dev team to see if I am making an incorrect assumption somewhere.

Thanks
-Alex

1 Like

devs do not give a bleep, If you do not use theirs supplied template, you have to override most of the toolkits. And at that point, paying $30 for an user/month is just a strange notion.

I’ve run in to the same issue. You have to un-comment:
“for key_name in search_template.keys” loop in work_area.py

Also override tk-core, context_from_path, otherwise you would not be able to get correct user from path, if user is part of filename as opposed to a directory name. Path_cache search will fail, so you will have to manually query using shotgun_api, for all unresolved keys.

edit:
for correct file filtering (file grouping), I had to add this. (we do not use users in published filenames)

  • file_model.py , func: _process_found_files
if file_list:
            file_list = [
                f for f in file_list
                    if (f.published_by and f.published_by['id'] == search_user['id'])
                        or not f.published_by
            ]