-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create & Publish: Attribute definitions per instance #860
Changes from 7 commits
d1bae6d
a1ca6a2
c337f2c
738cc82
cb3df92
e457580
35d7277
d970a1c
f526245
f03983d
bbd3881
b3f39ba
0770a26
cf41ab6
ee4ecf1
688c253
dbb427f
7427a07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
import copy | ||
import collections | ||
from typing import TYPE_CHECKING, Optional | ||
from typing import TYPE_CHECKING, Optional, Dict, Any | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
|
@@ -19,11 +19,12 @@ | |
from .product_name import get_product_name | ||
from .utils import get_next_versions_for_instances | ||
from .legacy_create import LegacyCreator | ||
from .structures import CreatedInstance | ||
|
||
if TYPE_CHECKING: | ||
from ayon_core.lib import AbstractAttrDef | ||
# Avoid cyclic imports | ||
from .context import CreateContext, CreatedInstance, UpdateData # noqa: F401 | ||
from .context import CreateContext, UpdateData # noqa: F401 | ||
|
||
|
||
class ProductConvertorPlugin(ABC): | ||
|
@@ -362,6 +363,18 @@ def log(self): | |
self._log = Logger.get_logger(self.__class__.__name__) | ||
return self._log | ||
|
||
def _create_instance( | ||
self, product_type: str, product_name: str, data: Dict[str, Any] | ||
) -> CreatedInstance: | ||
instance = CreatedInstance( | ||
product_type, | ||
product_name, | ||
data, | ||
creator=self, | ||
) | ||
self._add_instance_to_context(instance) | ||
return instance | ||
|
||
def _add_instance_to_context(self, instance): | ||
"""Helper method to add instance to create context. | ||
|
||
|
@@ -551,6 +564,16 @@ def get_instance_attr_defs(self): | |
|
||
return self.instance_attr_defs | ||
|
||
def get_attr_defs_for_instance(self, instance): | ||
"""Get attribute definitions for an instance. | ||
|
||
Args: | ||
instance (CreatedInstance): Instance for which to get | ||
attribute definitions. | ||
|
||
""" | ||
return self.get_instance_attr_defs() | ||
Comment on lines
+584
to
+592
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So - how dynamic is this? Like, from the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, but if I may request, please do not use Why: In case of USD, you probably should be adding
Both question have same answer. Right now it collects definitions only when instance is created or collected (on create and on reset). For "real time update" we need callbacks. Future PR mentioned in description, which I think might require change of the methods or create context api. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I see, but preferably we work towards something similar to if instance.supports("usd"):
# bla Likely overlaps tons with @antirotor work with OpenAssetIO but that's a can of worms I'm afraid to touch. :)
👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I don't know the context, I can't react. Only from what you wrote I have 10 following questions that will raise another questions. Maybe with full context I would agree, but at this moment I don't. It is possible to do anything, we should just discuss what would be the ideal approach, to make it clear from data flow. Like I've said (wrote) we can discuss that out of this PR, as it is not directly related, and it requires more minds. |
||
|
||
@property | ||
def collection_shared_data(self): | ||
"""Access to shared data that can be used during creator's collection. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just helper method for creators. Not needed, but you don't have to import
CreatedInstance
and call_add_instance_to_context
manually to create one.