Feature: Workfile Template Builder - #141
Conversation
|
Some review notes here while testing this in production that I thought would be helpful for general knowledge: At the moment, this PR is broken testing with ayon-core 1.9.8, and the underlying issue seems to still persist in 1.9.10 (version checked just now). def _collect_creators(self):
self._creators_by_name = {
identifier: creator
for identifier, creator
in self.create_context.manual_creators.items()
# Do not list HiddenCreator even though it is a 'manual creator'
if not isinstance(creator, HiddenCreator)
}It then gets sorted with a lambda, which fails to sort because it can't sort on a creators_by_name = self.builder.get_creators_by_name()
creator_items = [
(creator_name, creator.label or creator_name)
for creator_name, creator in creators_by_name.items()
]
# Errors on sort! Expects all keys to be strings.
creator_items.sort(key=lambda i: i[1])
options = options or {}There is no validation that's ran other than checking for inheritance of "HiddenCreator" who's only characteristic is that class HiddenCreator(BaseCreator):
# Maybe respect this class attribute over inheritance
skip_discovery = True
@abstractmethod
def create(
self,
instance_data: dict[str, Any],
source_data: dict[str, Any],
) -> Any:
passI know that automatic creators (that also have the I'd prefer it if we can simply set a flag and have it be respected, like the existing Kind regards, Sas |
|
@iLLiCiTiT can you check latest comment ☝️ |
Not sure I fully understand, but it sounds like a poor definition of what
I don't understand what do you mean by this? What validation? If you're asking about BTW the |
Yes, but oftentimes, implementations (such as this one, in harmony), set up their creators in a modular fashion, not completely implemented. They shouldn't have an identifier because they are merely there to set up some shared behavior. I'll go fetch an example, that most creator plugins for ayon_harmony inherit from. https://github.com/ynput/ayon-harmony/blob/develop/client/ayon_harmony/api/plugin.py#L87-L202 class HarmonyCreator(Creator, HarmonyCreatorBase):
"""Creator plugin to create instances in Harmony.
By default a Composite node is created to support any number of nodes in
an instance, but any node type is supported.
If the selection is used, the selected nodes will be connected to the
created node.
"""
settings_category = "harmony"
def create(self, product_name, instance_data, pre_create_data):
product_type = instance_data.get("productType")
if not product_type:
pt_items = self.get_product_type_items()
if pt_items:
product_type = pt_items[0].product_type
else:
product_type = self.product_base_type
instance_data["productType"] = product_type
# Create the node
node = self.product_impl(product_name, instance_data, pre_create_data)
# ... omitted the rest for the sake of lengthThis is a creator that never should be used in isolation, it is meant to be derived from. def product_impl(self, name, instance_data: dict, pre_create_data: dict):
raise NotImplementedErrorDespite all this, it's still collected, even though it has no identifier defined on the class, making it ill-formed, leading to errors.
With validation, I mean that there's no "check" that happens to see if the identifier is there, or if the plugin is even supposed to be picked up. The way the collection for the workfile template builder seems to work, it collects plugins from every source, and it doesnt "verify" them, only if they subclass from HiddenCreator do they not get picked up (as shown in my previous comment. I hope this clears things up a bit. Thanks, |
Oh I see, that's because the identifier by default uses product base type. But it means that is does define also
Well, the If you have base class that does implement all the abstract methods, then it is not really something we should handle, validating if abstract implementation actually does implement what the abstraction defines is double checking of the same thing. |
I see... Thanks, Sas |
|
Made a PR #148 |


I've based it on how the template builder works in Houdini and kept mostly the same logic
Few pointers:
update: draft removed, tested and linting fixed