Skip to content

Commit bd3b218

Browse files
committed
APP-7827: Added support for AttributeDef.Options.applicable_ai_asset_types
1 parent 5a52a5b commit bd3b218

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

pyatlan/model/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"AtlasGlossaryTerm",
1515
]
1616
]
17+
AIAssetTypes = Set[Literal["AIApplication", "AIModel"]]
1718
OtherAssetTypes = Set[Literal["File"]]
1819
AssetTypes = Set[
1920
Literal[

pyatlan/model/typedef.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from pyatlan.errors import ErrorCode
2222
from pyatlan.model.atlan_image import AtlanImage
2323
from pyatlan.model.constants import (
24+
AIAssetTypes,
2425
AssetTypes,
2526
DomainTypes,
2627
EntityTypes,
@@ -192,6 +193,7 @@
192193
"DataProduct",
193194
}
194195

196+
_all_ai_asset_types: AIAssetTypes = {"AIApplication", "AIModel"}
195197
_all_other_types: OtherAssetTypes = {"File"}
196198

197199

@@ -494,6 +496,12 @@ class Options(AtlanObject):
494496
"These cover asset types in data products and data domains. "
495497
"Only assets of one of these types will have this attribute available.",
496498
)
499+
applicable_ai_asset_types: Optional[str] = Field(
500+
default=None,
501+
alias="aiAssetsTypeList",
502+
description="AI asset type names to which this attribute is restricted. "
503+
"Only AI assets of the specified types will have this attribute available.",
504+
)
497505
applicable_other_asset_types: Optional[str] = Field(
498506
default=None,
499507
alias="otherAssetTypeList",
@@ -639,6 +647,7 @@ def __setattr__(self, name, value):
639647
"applicable_connections",
640648
"applicable_glossaries",
641649
"applicable_domains",
650+
"applicable_ai_asset_types",
642651
]
643652

644653
@property
@@ -747,6 +756,30 @@ def applicable_domain_types(self, domain_types: DomainTypes):
747756
)
748757
self.options.applicable_domain_types = json.dumps(list(domain_types))
749758

759+
@property
760+
def applicable_ai_asset_types(self) -> AIAssetTypes:
761+
"""
762+
AI asset type names to which this attribute is restricted.
763+
Only AI assets of the specified types will have this attribute available.
764+
"""
765+
if self.options and self.options.applicable_ai_asset_types:
766+
return set(json.loads(self.options.applicable_ai_asset_types))
767+
return set()
768+
769+
@applicable_ai_asset_types.setter
770+
def applicable_ai_asset_types(self, ai_asset_types: AIAssetTypes):
771+
if self.options is None:
772+
raise ErrorCode.MISSING_OPTIONS.exception_with_parameters()
773+
if not isinstance(ai_asset_types, set):
774+
raise ErrorCode.INVALID_PARAMETER_TYPE.exception_with_parameters(
775+
"applicable_ai_asset_types", AIAssetTypes
776+
)
777+
if not ai_asset_types.issubset(_all_ai_asset_types):
778+
raise ErrorCode.INVALID_PARAMETER_VALUE.exception_with_parameters(
779+
ai_asset_types, "applicable_ai_asset_types", _all_domain_types
780+
)
781+
self.options.applicable_ai_asset_types = json.dumps(list(ai_asset_types))
782+
750783
@property
751784
def applicable_other_asset_types(self) -> OtherAssetTypes:
752785
"""
@@ -855,6 +888,7 @@ def create(
855888
applicable_other_asset_types: Optional[OtherAssetTypes] = None,
856889
applicable_domains: Optional[Set[str]] = None,
857890
applicable_domain_types: Optional[DomainTypes] = None,
891+
applicable_ai_asset_types: Optional[AIAssetTypes] = None,
858892
description: Optional[str] = None,
859893
) -> AttributeDef:
860894
from pyatlan.utils import validate_required_fields
@@ -918,6 +952,7 @@ def create(
918952
applicable_glossaries or _get_all_qualified_names(client, "AtlasGlossary")
919953
)
920954
attr_def.applicable_domains = applicable_domains or _all_domains
955+
attr_def.applicable_ai_asset_types = applicable_ai_asset_types or set()
921956
return attr_def
922957

923958
def is_archived(self) -> bool:

tests/unit/test_typedef_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ def test_attribute_create_with_limited_applicability(self, client: AtlanClient):
424424
"default/snowflake/16992681799",
425425
},
426426
applicable_domains={"default/domain/uuBI8WSqeom1PXs7oo20L/super"},
427+
applicable_ai_asset_types={"AIModel", "AIApplication"},
427428
)
428429
attribute_def_with_limited = AttributeDef.create(
429430
client=client,

0 commit comments

Comments
 (0)