acryl-datahub-cloud 0.3.7.7rc4__py3-none-any.whl → 0.3.8rc0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of acryl-datahub-cloud might be problematic. Click here for more details.

Files changed (43) hide show
  1. acryl_datahub_cloud/_codegen_config.json +1 -1
  2. acryl_datahub_cloud/api/__init__.py +1 -0
  3. acryl_datahub_cloud/api/client.py +6 -0
  4. acryl_datahub_cloud/api/entity_versioning.py +167 -0
  5. acryl_datahub_cloud/lineage_features/source.py +22 -5
  6. acryl_datahub_cloud/metadata/_urns/urn_defs.py +54 -0
  7. acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/common/__init__.py +2 -0
  8. acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/metadata/key/__init__.py +2 -0
  9. acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/structured/__init__.py +2 -0
  10. acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/versionset/__init__.py +17 -0
  11. acryl_datahub_cloud/metadata/schema.avsc +312 -21
  12. acryl_datahub_cloud/metadata/schema_classes.py +420 -6
  13. acryl_datahub_cloud/metadata/schemas/AssertionAnalyticsRunEvent.avsc +1 -1
  14. acryl_datahub_cloud/metadata/schemas/AssertionInferenceDetails.avsc +1 -1
  15. acryl_datahub_cloud/metadata/schemas/AssertionInfo.avsc +1 -1
  16. acryl_datahub_cloud/metadata/schemas/AssertionRunEvent.avsc +1 -1
  17. acryl_datahub_cloud/metadata/schemas/DataHubIngestionSourceInfo.avsc +6 -0
  18. acryl_datahub_cloud/metadata/schemas/DataHubViewInfo.avsc +2 -0
  19. acryl_datahub_cloud/metadata/schemas/DatasetKey.avsc +2 -1
  20. acryl_datahub_cloud/metadata/schemas/Deprecation.avsc +12 -0
  21. acryl_datahub_cloud/metadata/schemas/DynamicFormAssignment.avsc +2 -0
  22. acryl_datahub_cloud/metadata/schemas/Filter.avsc +2 -0
  23. acryl_datahub_cloud/metadata/schemas/MLFeatureProperties.avsc +51 -0
  24. acryl_datahub_cloud/metadata/schemas/MLModelDeploymentProperties.avsc +51 -0
  25. acryl_datahub_cloud/metadata/schemas/MLModelGroupProperties.avsc +51 -0
  26. acryl_datahub_cloud/metadata/schemas/MLModelKey.avsc +2 -1
  27. acryl_datahub_cloud/metadata/schemas/MLModelProperties.avsc +51 -0
  28. acryl_datahub_cloud/metadata/schemas/MLPrimaryKeyProperties.avsc +51 -0
  29. acryl_datahub_cloud/metadata/schemas/MetadataChangeEvent.avsc +20 -0
  30. acryl_datahub_cloud/metadata/schemas/MonitorInfo.avsc +10 -1
  31. acryl_datahub_cloud/metadata/schemas/RecommendationModule.avsc +2 -0
  32. acryl_datahub_cloud/metadata/schemas/SchemaFieldKey.avsc +2 -1
  33. acryl_datahub_cloud/metadata/schemas/StructuredPropertyDefinition.avsc +2 -1
  34. acryl_datahub_cloud/metadata/schemas/StructuredPropertyKey.avsc +1 -0
  35. acryl_datahub_cloud/metadata/schemas/StructuredPropertySettings.avsc +114 -0
  36. acryl_datahub_cloud/metadata/schemas/VersionProperties.avsc +212 -0
  37. acryl_datahub_cloud/metadata/schemas/VersionSetKey.avsc +26 -0
  38. acryl_datahub_cloud/metadata/schemas/VersionSetProperties.avsc +49 -0
  39. {acryl_datahub_cloud-0.3.7.7rc4.dist-info → acryl_datahub_cloud-0.3.8rc0.dist-info}/METADATA +47 -47
  40. {acryl_datahub_cloud-0.3.7.7rc4.dist-info → acryl_datahub_cloud-0.3.8rc0.dist-info}/RECORD +43 -35
  41. {acryl_datahub_cloud-0.3.7.7rc4.dist-info → acryl_datahub_cloud-0.3.8rc0.dist-info}/WHEEL +0 -0
  42. {acryl_datahub_cloud-0.3.7.7rc4.dist-info → acryl_datahub_cloud-0.3.8rc0.dist-info}/entry_points.txt +0 -0
  43. {acryl_datahub_cloud-0.3.7.7rc4.dist-info → acryl_datahub_cloud-0.3.8rc0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acryl-datahub-cloud",
3
- "version": "0.3.7.7rc4",
3
+ "version": "0.3.8rc0",
4
4
  "install_requires": [
5
5
  "avro-gen3==0.7.16",
6
6
  "acryl-datahub"
@@ -0,0 +1 @@
1
+ from acryl_datahub_cloud.api.client import AcrylGraph
@@ -0,0 +1,6 @@
1
+ from acryl_datahub_cloud.api.entity_versioning import EntityVersioningAPI
2
+ from datahub.ingestion.graph.client import DataHubGraph
3
+
4
+
5
+ class AcrylGraph(EntityVersioningAPI, DataHubGraph):
6
+ pass
@@ -0,0 +1,167 @@
1
+ import uuid
2
+ from typing import Optional
3
+
4
+ from datahub.ingestion.graph.client import DataHubGraph
5
+ from datahub.metadata.schema_classes import (
6
+ VersionPropertiesClass,
7
+ VersionSetPropertiesClass,
8
+ )
9
+ from datahub.metadata.urns import VersionSetUrn
10
+ from datahub.utilities.urns.urn import guess_entity_type
11
+
12
+
13
+ class EntityVersioningAPI(DataHubGraph):
14
+ LINK_VERSION_MUTATION = """
15
+ mutation($input: LinkVersionInput!) {
16
+ linkAssetVersion(input: $input)
17
+ }
18
+ """
19
+
20
+ UNLINK_VERSION_MUTATION = """
21
+ mutation($input: UnlinkVersionInput!) {
22
+ unlinkAssetVersion(input: $input)
23
+ }
24
+ """
25
+
26
+ def link_asset_to_version_set(
27
+ self,
28
+ asset_urn: str,
29
+ version_set_urn: Optional[str],
30
+ label: str,
31
+ *,
32
+ comment: Optional[str] = None,
33
+ ) -> str:
34
+ """Sets an entity as the latest version of a version set.
35
+
36
+ Can also be used to create a new version set, with `asset_urn` as the first version.
37
+
38
+ Args:
39
+ asset_urn: URN of the entity.
40
+ version_set_urn: URN of the version set, or None to generate a new version set urn
41
+ label: Label of the version.
42
+ comment: Comment about the version.
43
+
44
+ Returns:
45
+ URN of the version set to which `asset_urn` was linked.
46
+ """
47
+
48
+ entity_type = guess_entity_type(asset_urn)
49
+ if version_set_urn is None:
50
+ version_set_urn = VersionSetUrn(str(uuid.uuid4()), entity_type).urn()
51
+ elif guess_entity_type(version_set_urn) != "versionSet":
52
+ raise ValueError(f"Expected version set URN, got {version_set_urn}")
53
+
54
+ entity_version = self.get_aspect(asset_urn, VersionPropertiesClass)
55
+ if entity_version:
56
+ raise ValueError(
57
+ f"Asset {asset_urn} is already a version of {entity_version.versionSet}"
58
+ )
59
+
60
+ variables = {
61
+ "input": {
62
+ "versionSet": version_set_urn,
63
+ "linkedEntity": asset_urn,
64
+ "version": label,
65
+ "comment": comment,
66
+ }
67
+ }
68
+ self.execute_graphql(self.LINK_VERSION_MUTATION, variables)
69
+ return version_set_urn
70
+
71
+ def link_asset_to_versioned_asset(
72
+ self,
73
+ new_asset_urn: str,
74
+ old_asset_urn: str,
75
+ label: str,
76
+ *,
77
+ comment: Optional[str] = None,
78
+ ) -> str:
79
+ """Sets an entity as the latest version of an existing versioned entity.
80
+
81
+ Args:
82
+ new_asset_urn: URN of the new latest entity.
83
+ old_asset_urn: URN of an existing versioned entity to link onto.
84
+ label: Label of the version.
85
+ comment: Comment about the version.
86
+
87
+ Returns:
88
+ URN of the version set to which `new_asset_urn` was linked.
89
+ """
90
+
91
+ new_entity_type = guess_entity_type(new_asset_urn)
92
+ old_entity_type = guess_entity_type(old_asset_urn)
93
+ if new_entity_type != old_entity_type:
94
+ raise ValueError(
95
+ f"Expected URNs of the same type, got {new_entity_type} and {old_entity_type}"
96
+ )
97
+
98
+ new_entity_version = self.get_aspect(new_asset_urn, VersionPropertiesClass)
99
+ if new_entity_version:
100
+ raise ValueError(
101
+ f"Asset {new_asset_urn} is already a version of {new_entity_version.versionSet}"
102
+ )
103
+ old_entity_version = self.get_aspect(old_asset_urn, VersionPropertiesClass)
104
+ if not old_entity_version:
105
+ raise ValueError(f"Asset {old_asset_urn} is not versioned")
106
+
107
+ version_set_urn = old_entity_version.versionSet
108
+ self.link_asset_to_version_set(
109
+ new_asset_urn, version_set_urn, label, comment=comment
110
+ )
111
+ return version_set_urn
112
+
113
+ def unlink_asset_from_version_set(self, asset_urn: str) -> Optional[str]:
114
+ """Unlinks an entity from its version set.
115
+
116
+ Args:
117
+ asset_urn: URN of the entity to unlink from its version set.
118
+
119
+ Returns:
120
+ If successful, the URN of the version set from which `asset_urn` was unlinked.
121
+ """
122
+
123
+ entity_version = self.get_aspect(asset_urn, VersionPropertiesClass)
124
+ if not entity_version:
125
+ raise ValueError(f"Asset {asset_urn} is not versioned")
126
+
127
+ variables = {
128
+ "input": {
129
+ "versionSet": entity_version.versionSet,
130
+ "unlinkedEntity": asset_urn,
131
+ }
132
+ }
133
+ if self.execute_graphql(self.UNLINK_VERSION_MUTATION, variables):
134
+ return entity_version.versionSet
135
+ else:
136
+ return None
137
+
138
+ def unlink_latest_asset_from_version_set(
139
+ self, version_set_urn: str
140
+ ) -> Optional[str]:
141
+ """Unlinks the latest version of a version set.
142
+
143
+ Args:
144
+ version_set_urn: URN of the version set.
145
+
146
+ Returns:
147
+ If successful, the URN of the entity that was unlinked from `version_set_urn`.
148
+ """
149
+
150
+ version_set_properties = self.get_aspect(
151
+ version_set_urn, VersionSetPropertiesClass
152
+ )
153
+ if not version_set_properties:
154
+ raise ValueError(
155
+ f"Version set {version_set_urn} does not exist or has no versions"
156
+ )
157
+
158
+ variables = {
159
+ "input": {
160
+ "versionSet": version_set_urn,
161
+ "unlinkedEntity": version_set_properties.latest,
162
+ }
163
+ }
164
+ if self.execute_graphql(self.UNLINK_VERSION_MUTATION, variables):
165
+ return version_set_properties.latest
166
+ else:
167
+ return None
@@ -83,16 +83,31 @@ class DataHubLineageFeaturesSource(Source):
83
83
  query = {
84
84
  "query": {
85
85
  "bool": {
86
- "filter": [
87
- {"term": {"source.entityType": "schemaField"}},
88
- {"term": {"destination.entityType": "schemaField"}},
86
+ "should": [
87
+ {"term": {"relationshipType": "Consumes"}},
89
88
  {"term": {"relationshipType": "DownstreamOf"}},
89
+ {"term": {"relationshipType": "TrainedBy"}},
90
+ {"term": {"relationshipType": "UsedBy"}},
91
+ {"term": {"relationshipType": "MemberOf"}},
92
+ {"term": {"relationshipType": "DerivedFrom"}},
93
+ {"term": {"relationshipType": "Produces"}},
94
+ {"term": {"relationshipType": "DashboardContainsDashboard"}},
95
+ {
96
+ "bool": {
97
+ "must": [
98
+ {"term": {"relationshipType": "Contains"}},
99
+ {"term": {"source.entityType": "dashboard"}},
100
+ {"term": {"destination.entityType": "chart"}},
101
+ ]
102
+ }
103
+ },
90
104
  ],
91
- }
105
+ },
92
106
  },
93
107
  "sort": [
94
108
  {"source.urn": {"order": "desc"}},
95
109
  {"destination.urn": {"order": "desc"}},
110
+ {"relationshipType": {"order": "desc"}},
96
111
  {"lifecycleOwner": {"order": "desc"}},
97
112
  ],
98
113
  }
@@ -124,7 +139,9 @@ class DataHubLineageFeaturesSource(Source):
124
139
  for urn in set(self.upstream_counts.keys()).union(
125
140
  self.downstream_counts.keys()
126
141
  ):
127
- print(urn, self.upstream_counts[urn], self.downstream_counts[urn])
142
+ logger.debug(
143
+ f"{urn}: {self.upstream_counts[urn]}, {self.downstream_counts[urn]}"
144
+ )
128
145
  yield MetadataChangeProposalWrapper(
129
146
  entityUrn=urn,
130
147
  aspect=LineageFeaturesClass(
@@ -21,6 +21,60 @@ from datahub.utilities.urns.error import InvalidUrnError
21
21
 
22
22
  deprecated = functools.partial(_sphinx_deprecated, version="0.12.0.2")
23
23
 
24
+ if TYPE_CHECKING:
25
+ from datahub.metadata.schema_classes import VersionSetKeyClass
26
+
27
+ class VersionSetUrn(_SpecificUrn):
28
+ ENTITY_TYPE: ClassVar[str] = "versionSet"
29
+ URN_PARTS: ClassVar[int] = 2
30
+
31
+ def __init__(self, id: str, entity_type: str, *, _allow_coercion: bool = True) -> None:
32
+ if _allow_coercion:
33
+ # Field coercion logic (if any is required).
34
+ id = UrnEncoder.encode_string(id)
35
+ entity_type = UrnEncoder.encode_string(entity_type)
36
+
37
+ # Validation logic.
38
+ if not id:
39
+ raise InvalidUrnError("VersionSetUrn id cannot be empty")
40
+ if UrnEncoder.contains_reserved_char(id):
41
+ raise InvalidUrnError(f'VersionSetUrn id contains reserved characters')
42
+ if not entity_type:
43
+ raise InvalidUrnError("VersionSetUrn entity_type cannot be empty")
44
+ if UrnEncoder.contains_reserved_char(entity_type):
45
+ raise InvalidUrnError(f'VersionSetUrn entity_type contains reserved characters')
46
+
47
+ super().__init__(self.ENTITY_TYPE, [id, entity_type])
48
+
49
+ @classmethod
50
+ def _parse_ids(cls, entity_ids: List[str]) -> "VersionSetUrn":
51
+ if len(entity_ids) != cls.URN_PARTS:
52
+ raise InvalidUrnError(f"VersionSetUrn should have {cls.URN_PARTS} parts, got {len(entity_ids)}: {entity_ids}")
53
+ return cls(id=entity_ids[0], entity_type=entity_ids[1], _allow_coercion=False)
54
+
55
+ @classmethod
56
+ def underlying_key_aspect_type(cls) -> Type["VersionSetKeyClass"]:
57
+ from datahub.metadata.schema_classes import VersionSetKeyClass
58
+
59
+ return VersionSetKeyClass
60
+
61
+ def to_key_aspect(self) -> "VersionSetKeyClass":
62
+ from datahub.metadata.schema_classes import VersionSetKeyClass
63
+
64
+ return VersionSetKeyClass(id=self.id, entityType=self.entity_type)
65
+
66
+ @classmethod
67
+ def from_key_aspect(cls, key_aspect: "VersionSetKeyClass") -> "VersionSetUrn":
68
+ return cls(id=key_aspect.id, entity_type=key_aspect.entityType)
69
+
70
+ @property
71
+ def id(self) -> str:
72
+ return self.entity_ids[0]
73
+
74
+ @property
75
+ def entity_type(self) -> str:
76
+ return self.entity_ids[1]
77
+
24
78
  if TYPE_CHECKING:
25
79
  from datahub.metadata.schema_classes import DataHubConnectionKeyClass
26
80
 
@@ -87,6 +87,7 @@ from .....schema_classes import SubTypesClass
87
87
  from .....schema_classes import SyncMechanismClass
88
88
  from .....schema_classes import TagAssociationClass
89
89
  from .....schema_classes import TimeStampClass
90
+ from .....schema_classes import VersionPropertiesClass
90
91
  from .....schema_classes import VersionTagClass
91
92
  from .....schema_classes import WindowDurationClass
92
93
 
@@ -171,6 +172,7 @@ SubTypes = SubTypesClass
171
172
  SyncMechanism = SyncMechanismClass
172
173
  TagAssociation = TagAssociationClass
173
174
  TimeStamp = TimeStampClass
175
+ VersionProperties = VersionPropertiesClass
174
176
  VersionTag = VersionTagClass
175
177
  WindowDuration = WindowDurationClass
176
178
 
@@ -65,6 +65,7 @@ from ......schema_classes import SubscriptionKeyClass
65
65
  from ......schema_classes import TagKeyClass
66
66
  from ......schema_classes import TelemetryKeyClass
67
67
  from ......schema_classes import TestKeyClass
68
+ from ......schema_classes import VersionSetKeyClass
68
69
 
69
70
 
70
71
  ActionRequestKey = ActionRequestKeyClass
@@ -125,5 +126,6 @@ SubscriptionKey = SubscriptionKeyClass
125
126
  TagKey = TagKeyClass
126
127
  TelemetryKey = TelemetryKeyClass
127
128
  TestKey = TestKeyClass
129
+ VersionSetKey = VersionSetKeyClass
128
130
 
129
131
  # fmt: on
@@ -13,6 +13,7 @@ from .....schema_classes import StructuredPropertiesClass
13
13
  from .....schema_classes import StructuredPropertyDefinitionClass
14
14
  from .....schema_classes import StructuredPropertyFilterStatusClass
15
15
  from .....schema_classes import StructuredPropertyKeyClass
16
+ from .....schema_classes import StructuredPropertySettingsClass
16
17
  from .....schema_classes import StructuredPropertyValueAssignmentClass
17
18
 
18
19
 
@@ -22,6 +23,7 @@ StructuredProperties = StructuredPropertiesClass
22
23
  StructuredPropertyDefinition = StructuredPropertyDefinitionClass
23
24
  StructuredPropertyFilterStatus = StructuredPropertyFilterStatusClass
24
25
  StructuredPropertyKey = StructuredPropertyKeyClass
26
+ StructuredPropertySettings = StructuredPropertySettingsClass
25
27
  StructuredPropertyValueAssignment = StructuredPropertyValueAssignmentClass
26
28
 
27
29
  # fmt: on
@@ -0,0 +1,17 @@
1
+ # mypy: ignore-errors
2
+ # flake8: noqa
3
+
4
+ # This file is autogenerated by /metadata-ingestion/scripts/avro_codegen.py
5
+ # Do not modify manually!
6
+
7
+ # pylint: skip-file
8
+ # fmt: off
9
+ # isort: skip_file
10
+ from .....schema_classes import VersionSetPropertiesClass
11
+ from .....schema_classes import VersioningSchemeClass
12
+
13
+
14
+ VersionSetProperties = VersionSetPropertiesClass
15
+ VersioningScheme = VersioningSchemeClass
16
+
17
+ # fmt: on