Refactoring templates

Hey Mois – moved this one over to the Pipeline Integrations category so we can get more Toolkit eyes on it.

One thing you might want to consider is using separate files to organize your templates via includes – doesn’t limit the quantity of templates you have, but at least makes the files shorter and hopefully easier to look at.

Here’s a simple example using includes in templates.yml:

templates.yml (not including all of it here, just the important bits)

include: "./test.yml"


paths:


    sequence_root: sequences/{Sequence}

    foo_bar_in_master: "@sequence_root/@foo_bar" 

And the included test.yml file:

keys:
    Foo:
        type: str
    Bar:
        type: str

paths:
    foo_bar: test_path/{Foo}/{Bar}

strings:
    foo_bar_name: "string_{Foo}_{Bar}"

And when I run this in a shell, I get:

>>> tk.templates["foo_bar"]
<Sgtk TemplatePath foo_bar: test_path/{Foo}/{Bar}>
>>> tk.templates["foo_bar_name"]
<Sgtk TemplateString foo_bar_name: string_{Foo}_{Bar}>
>>> tk.templates["foo_bar_in_master"]
<Sgtk TemplatePath foo_bar_in_master: sequences/{Sequence}/test_path/{Foo}/{Bar}>

Beyond that, I’m spitballing, but maybe it’d be helpful to employ some sort of bidirectional conversion between YAML and CSV, so you can view/edit your data in Google Sheets or Excel?

And, beyond that, :crossed_fingers: that you get some good ideas from the community. Good luck!

4 Likes