Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion pyatlan/model/assets/core/skill_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pydantic.v1 import Field, validator

from pyatlan.model.enums import FileType
from pyatlan.model.fields.atlan_fields import RelationField
from pyatlan.model.fields.atlan_fields import KeywordField, RelationField
from pyatlan.utils import init_guid, validate_required_fields

from .artifact import Artifact
Expand Down Expand Up @@ -49,15 +49,37 @@ def __setattr__(self, name, value):
return object.__setattr__(self, name, value)
super().__setattr__(name, value)

SKILL_ARTIFACT_CONTENT: ClassVar[KeywordField] = KeywordField(
"skillArtifactContent", "skillArtifactContent"
)
"""
Content of the skill artifact (e.g. the body of a skill .md file).
"""

SKILL_SOURCE: ClassVar[RelationField] = RelationField("skillSource")
"""
TBC
"""

_convenience_properties: ClassVar[List[str]] = [
"skill_artifact_content",
"skill_source",
]

@property
def skill_artifact_content(self) -> Optional[str]:
return (
None
if self.attributes is None
else self.attributes.skill_artifact_content
)

@skill_artifact_content.setter
def skill_artifact_content(self, skill_artifact_content: Optional[str]):
if self.attributes is None:
self.attributes = self.Attributes()
self.attributes.skill_artifact_content = skill_artifact_content

@property
def skill_source(self) -> Optional[Skill]:
return None if self.attributes is None else self.attributes.skill_source
Expand All @@ -69,6 +91,9 @@ def skill_source(self, skill_source: Optional[Skill]):
self.attributes.skill_source = skill_source

class Attributes(Artifact.Attributes):
skill_artifact_content: Optional[str] = Field(
default=None, description=""
)
skill_source: Optional[Skill] = Field(
default=None, description=""
) # relationship
Expand Down
12 changes: 12 additions & 0 deletions pyatlan_v9/model/assets/skill_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class SkillArtifact(Asset):
LINKS: ClassVar[Any] = None
README: ClassVar[Any] = None
SCHEMA_REGISTRY_SUBJECTS: ClassVar[Any] = None
SKILL_ARTIFACT_CONTENT: ClassVar[Any] = None
SKILL_SOURCE: ClassVar[Any] = None
SODA_CHECKS: ClassVar[Any] = None
INPUT_TO_SPARK_JOBS: ClassVar[Any] = None
Expand Down Expand Up @@ -134,6 +135,9 @@ class SkillArtifact(Asset):
resource_metadata: Union[Dict[str, str], None, UnsetType] = UNSET
"""Metadata of the resource."""

skill_artifact_content: Union[str, None, UnsetType] = UNSET
"""Content of the skill artifact (e.g. the body of a skill .md file)."""

input_to_airflow_tasks: Union[List[RelatedAirflowTask], None, UnsetType] = UNSET
"""Tasks to which this asset provides input."""

Expand Down Expand Up @@ -388,6 +392,9 @@ class SkillArtifactAttributes(AssetAttributes):
resource_metadata: Union[Dict[str, str], None, UnsetType] = UNSET
"""Metadata of the resource."""

skill_artifact_content: Union[str, None, UnsetType] = UNSET
"""Content of the skill artifact (e.g. the body of a skill .md file)."""


class SkillArtifactRelationshipAttributes(AssetRelationshipAttributes):
"""SkillArtifact-specific relationship attributes for nested API format."""
Expand Down Expand Up @@ -569,6 +576,7 @@ def _populate_skill_artifact_attrs(
attrs.is_global = obj.is_global
attrs.reference = obj.reference
attrs.resource_metadata = obj.resource_metadata
attrs.skill_artifact_content = obj.skill_artifact_content


def _extract_skill_artifact_attrs(attrs: SkillArtifactAttributes) -> dict:
Expand All @@ -583,6 +591,7 @@ def _extract_skill_artifact_attrs(attrs: SkillArtifactAttributes) -> dict:
result["is_global"] = attrs.is_global
result["reference"] = attrs.reference
result["resource_metadata"] = attrs.resource_metadata
result["skill_artifact_content"] = attrs.skill_artifact_content
return result


Expand Down Expand Up @@ -738,6 +747,9 @@ def _skill_artifact_from_nested_bytes(data: bytes, serde: Serde) -> SkillArtifac
SkillArtifact.LINKS = RelationField("links")
SkillArtifact.README = RelationField("readme")
SkillArtifact.SCHEMA_REGISTRY_SUBJECTS = RelationField("schemaRegistrySubjects")
SkillArtifact.SKILL_ARTIFACT_CONTENT = KeywordField(
"skillArtifactContent", "skillArtifactContent"
)
SkillArtifact.SKILL_SOURCE = RelationField("skillSource")
SkillArtifact.SODA_CHECKS = RelationField("sodaChecks")
SkillArtifact.INPUT_TO_SPARK_JOBS = RelationField("inputToSparkJobs")
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/model/skill_artifact_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,23 @@ def test_type_name_is_immutable():
)
with pytest.raises(TypeError):
sut.type_name = "NotSkillArtifact"


def test_skill_artifact_content_defaults_to_none():
sut = SkillArtifact.creator(
name=SKILL_ARTIFACT_NAME,
skill_qualified_name=SKILL_QUALIFIED_NAME,
file_type=FileType.TXT,
)
assert sut.skill_artifact_content is None


def test_skill_artifact_content_roundtrip():
sut = SkillArtifact.creator(
name=SKILL_ARTIFACT_NAME,
skill_qualified_name=SKILL_QUALIFIED_NAME,
file_type=FileType.TXT,
)
content = "# My Skill\nThis skill does X when Y."
sut.skill_artifact_content = content
assert sut.skill_artifact_content == content
Loading