ynput / OpenPype

OpenPype has been surpassed by AYON and is now read only.
https://ayon.ynput.io
MIT License
286 stars 129 forks source link

Repeated nested folders created when FTrack->Create Project Structure clicked and you have multiple roots #3699

Open dmo-j-cube opened 2 years ago

dmo-j-cube commented 2 years ago

Describe the bug When you have multiple roots in your project anatomy (eg: publish, work, render), and click on Create Project Structure in FTrack's webUI, you will get repeated nested directories created in your folder. Example with ProjectName=Blah and 3 roots:

└───Blah
    ├───asset
    ├───editorial
    ├───prod
    ├───resources
    │   ├───art_dept
    │   ├───audio
    │   └───footage
    │       ├───offline
    │       └───plates
    └───Blah
        ├───asset
        ├───editorial
        ├───prod
        ├───resources
        │   ├───art_dept
        │   ├───audio
        │   └───footage
        │       ├───offline
        │       └───plates
        └───Blah
            ├───asset
            ├───editorial
            ├───prod
            └───resources
                ├───art_dept
                ├───audio
                └───footage
                    ├───offline
                    └───plates

To Reproduce Steps to reproduce the behavior:

  1. Create a blank new project in OP's Admin Settings.
  2. Create multiple roots under Default : project_anatomy/roots, eg: work, render, publish
  3. Save and launch the FTrack webUI
  4. Create project (eg: Blah) and follow OP's instructions for initial setup
  5. Click on Create Project Structure
  6. Nested directories will be created (see above)

Expected behavior Only a single set of directories should be created.

Desktop (please complete the following information):

Additional context I tried to track the issue down to openpype/lib/path_tools.py, in concatenate_splitted_paths(), in the __project_root__ section, the first element of clean_items is replaced with two items for every anatomy.roots item. This means that the second anatomy.roots iteration will contain two {project[name]} elements, and the third iteration will contain 3, etc.

A suggested fix would be to make a local copy of clean_items in that for loop, and use that cleanly on each iteration, similar to the attached patch file.

The attached file also contains the dump of the variables split_paths & anatomy to concatenate_splitted_paths():.

OpenPype_FTrack_Mutliple_Roots.zip

[cuID:OP-3762]

BigRoy commented 2 years ago

Host: FTrack?

I believe the same create button is present in the Project Manager as Create Starting Folders so this shouldn't be necessarily tied to a an implementation like Ftrack.


For future reference, this also came up on OpenPype discord here.


Does this work?

With multiple roots defined what __project_root__ would you have it expected to take? Since it doesn't know it assumes all created roots.

I believe __project_root__ is the older deprecated way of doing this (from back when there was only ever one root) and instead it's recommended to use {root[work]} and explicitly state what root you would like it to use. The __project_root__ will assume all available roots (and only returns the ones of which the path exists.)

tl;dr

Try {root[work]} instead of __project_root__ (older; see backward compatibility notice)

One could argue that if that works, that potentially {root[work]} is a more sensible default value than __project_root__ for the starting folders.

mkolar commented 2 years ago

This is archaic part of code that I believe doesn't use anatomy at all. We've known for a while that it should be re-written, made completely separate from ftrack, we just never got to it.

This was really only used for simple scenarios of setting up the first few folders and never received a whole lot of love afterwards. I'd say it also needs a bit of discussion about what it's responsibilites should really be. @iLLiCiTiT has been bringing this up in the office repeatedly actually, but it tends to slip down priorities as it's used so little.

BigRoy commented 2 years ago

It should be able to format against this data when looking at the code.

Because create_project_folders - fills the paths which formats against that format data. Since anatomy.roots is a Roots instance it should allow indexing by key like {root[work]}.

So this example should work:

{
    "{root[work]}": {
        "prod": {},
        "resources": {
            "footage": {
                "plates": {},
                "offline": {}
            },
            "audio": {},
            "art_dept": {}
        },
        "editorial": {},
        "assets": {
            "characters": {},
            "locations": {}
        },
        "shots": {}
    }
}

Untested - but I don't see a reason in the code why it should fail to do so. Of course my snippet assumes you have a root defined that's named "work" - which should be there by default.


Also mentioned on discord