acryl-datahub-cloud 0.3.11.1rc7__py3-none-any.whl → 0.3.12__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 (94) hide show
  1. acryl_datahub_cloud/_codegen_config.json +1 -1
  2. acryl_datahub_cloud/action_request/action_request_owner_source.py +36 -6
  3. acryl_datahub_cloud/datahub_forms_notifications/__init__.py +0 -0
  4. acryl_datahub_cloud/datahub_forms_notifications/forms_notifications_source.py +569 -0
  5. acryl_datahub_cloud/datahub_forms_notifications/get_feature_flag.gql +7 -0
  6. acryl_datahub_cloud/datahub_forms_notifications/get_search_results_total.gql +14 -0
  7. acryl_datahub_cloud/datahub_forms_notifications/query.py +17 -0
  8. acryl_datahub_cloud/datahub_forms_notifications/scroll_forms_for_notification.gql +29 -0
  9. acryl_datahub_cloud/datahub_forms_notifications/send_form_notification_request.gql +5 -0
  10. acryl_datahub_cloud/datahub_reporting/datahub_form_reporting.py +29 -13
  11. acryl_datahub_cloud/datahub_usage_reporting/query_builder.py +48 -8
  12. acryl_datahub_cloud/datahub_usage_reporting/usage_feature_reporter.py +49 -40
  13. acryl_datahub_cloud/metadata/_urns/urn_defs.py +2011 -1955
  14. acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/application/__init__.py +19 -0
  15. acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/assertion/__init__.py +2 -2
  16. acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/form/__init__.py +8 -0
  17. acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/notification/__init__.py +19 -0
  18. acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/settings/global/__init__.py +2 -0
  19. acryl_datahub_cloud/metadata/schema.avsc +25413 -25425
  20. acryl_datahub_cloud/metadata/schema_classes.py +1316 -791
  21. acryl_datahub_cloud/metadata/schemas/ApplicationKey.avsc +31 -0
  22. acryl_datahub_cloud/metadata/schemas/ApplicationProperties.avsc +72 -0
  23. acryl_datahub_cloud/metadata/schemas/Applications.avsc +38 -0
  24. acryl_datahub_cloud/metadata/schemas/AssertionAnalyticsRunEvent.avsc +223 -202
  25. acryl_datahub_cloud/metadata/schemas/AssertionInfo.avsc +36 -7
  26. acryl_datahub_cloud/metadata/schemas/AssertionKey.avsc +1 -1
  27. acryl_datahub_cloud/metadata/schemas/AssertionRunEvent.avsc +40 -8
  28. acryl_datahub_cloud/metadata/schemas/{AssertionSummary.avsc → AssertionRunSummary.avsc} +2 -2
  29. acryl_datahub_cloud/metadata/schemas/AssertionsSummary.avsc +14 -0
  30. acryl_datahub_cloud/metadata/schemas/ChartKey.avsc +1 -0
  31. acryl_datahub_cloud/metadata/schemas/ConstraintInfo.avsc +12 -1
  32. acryl_datahub_cloud/metadata/schemas/ContainerKey.avsc +1 -0
  33. acryl_datahub_cloud/metadata/schemas/CorpGroupKey.avsc +2 -1
  34. acryl_datahub_cloud/metadata/schemas/CorpUserKey.avsc +2 -1
  35. acryl_datahub_cloud/metadata/schemas/DashboardKey.avsc +1 -0
  36. acryl_datahub_cloud/metadata/schemas/DataFlowKey.avsc +1 -0
  37. acryl_datahub_cloud/metadata/schemas/DataHubIngestionSourceKey.avsc +2 -1
  38. acryl_datahub_cloud/metadata/schemas/DataHubPolicyInfo.avsc +12 -1
  39. acryl_datahub_cloud/metadata/schemas/DataJobKey.avsc +1 -0
  40. acryl_datahub_cloud/metadata/schemas/DataProductKey.avsc +1 -0
  41. acryl_datahub_cloud/metadata/schemas/DataProductProperties.avsc +1 -1
  42. acryl_datahub_cloud/metadata/schemas/DatasetKey.avsc +1 -0
  43. acryl_datahub_cloud/metadata/schemas/FormAssignmentStatus.avsc +36 -0
  44. acryl_datahub_cloud/metadata/schemas/FormInfo.avsc +6 -0
  45. acryl_datahub_cloud/metadata/schemas/FormKey.avsc +3 -1
  46. acryl_datahub_cloud/metadata/schemas/FormNotifications.avsc +69 -0
  47. acryl_datahub_cloud/metadata/schemas/FormSettings.avsc +30 -0
  48. acryl_datahub_cloud/metadata/schemas/GlobalSettingsInfo.avsc +22 -0
  49. acryl_datahub_cloud/metadata/schemas/GlossaryTermKey.avsc +1 -0
  50. acryl_datahub_cloud/metadata/schemas/MLFeatureKey.avsc +1 -0
  51. acryl_datahub_cloud/metadata/schemas/MLFeatureTableKey.avsc +1 -0
  52. acryl_datahub_cloud/metadata/schemas/MLModelGroupKey.avsc +1 -0
  53. acryl_datahub_cloud/metadata/schemas/MLModelKey.avsc +1 -0
  54. acryl_datahub_cloud/metadata/schemas/MLPrimaryKeyKey.avsc +1 -0
  55. acryl_datahub_cloud/metadata/schemas/MetadataChangeEvent.avsc +12 -1
  56. acryl_datahub_cloud/metadata/schemas/MonitorAnomalyEvent.avsc +21 -9
  57. acryl_datahub_cloud/metadata/schemas/MonitorInfo.avsc +39 -10
  58. acryl_datahub_cloud/metadata/schemas/MonitorSuiteInfo.avsc +1 -1
  59. acryl_datahub_cloud/metadata/schemas/NotebookKey.avsc +1 -0
  60. acryl_datahub_cloud/metadata/schemas/NotificationRequest.avsc +1 -0
  61. acryl_datahub_cloud/metadata/schemas/Operation.avsc +17 -0
  62. acryl_datahub_cloud/metadata/schemas/SubscriptionInfo.avsc +3 -3
  63. acryl_datahub_cloud/metadata/schemas/SubscriptionKey.avsc +2 -1
  64. acryl_datahub_cloud/metadata/schemas/UsageFeatures.avsc +10 -0
  65. acryl_datahub_cloud/metadata/schemas/__init__.py +3 -3
  66. acryl_datahub_cloud/notifications/__init__.py +0 -0
  67. acryl_datahub_cloud/notifications/notification_recipient_builder.py +399 -0
  68. acryl_datahub_cloud/sdk/__init__.py +39 -0
  69. acryl_datahub_cloud/sdk/assertion/__init__.py +0 -0
  70. acryl_datahub_cloud/sdk/assertion/assertion_base.py +1467 -0
  71. acryl_datahub_cloud/sdk/assertion/smart_column_metric_assertion.py +224 -0
  72. acryl_datahub_cloud/sdk/assertion/types.py +20 -0
  73. acryl_datahub_cloud/sdk/assertion_input/__init__.py +0 -0
  74. acryl_datahub_cloud/sdk/assertion_input/assertion_input.py +1648 -0
  75. acryl_datahub_cloud/sdk/assertion_input/freshness_assertion_input.py +258 -0
  76. acryl_datahub_cloud/sdk/assertion_input/smart_column_metric_assertion_input.py +914 -0
  77. acryl_datahub_cloud/sdk/assertion_input/sql_assertion_input.py +272 -0
  78. acryl_datahub_cloud/sdk/assertion_input/volume_assertion_input.py +648 -0
  79. acryl_datahub_cloud/sdk/assertions_client.py +3206 -0
  80. acryl_datahub_cloud/sdk/entities/__init__.py +0 -0
  81. acryl_datahub_cloud/sdk/entities/assertion.py +432 -0
  82. acryl_datahub_cloud/sdk/entities/monitor.py +291 -0
  83. acryl_datahub_cloud/sdk/entities/subscription.py +84 -0
  84. acryl_datahub_cloud/sdk/errors.py +34 -0
  85. acryl_datahub_cloud/sdk/resolver_client.py +39 -0
  86. acryl_datahub_cloud/sdk/subscription_client.py +714 -0
  87. {acryl_datahub_cloud-0.3.11.1rc7.dist-info → acryl_datahub_cloud-0.3.12.dist-info}/METADATA +47 -42
  88. {acryl_datahub_cloud-0.3.11.1rc7.dist-info → acryl_datahub_cloud-0.3.12.dist-info}/RECORD +91 -58
  89. {acryl_datahub_cloud-0.3.11.1rc7.dist-info → acryl_datahub_cloud-0.3.12.dist-info}/WHEEL +1 -1
  90. {acryl_datahub_cloud-0.3.11.1rc7.dist-info → acryl_datahub_cloud-0.3.12.dist-info}/entry_points.txt +1 -0
  91. acryl_datahub_cloud/_sdk_extras/__init__.py +0 -4
  92. acryl_datahub_cloud/_sdk_extras/assertion.py +0 -15
  93. acryl_datahub_cloud/_sdk_extras/assertions_client.py +0 -23
  94. {acryl_datahub_cloud-0.3.11.1rc7.dist-info → acryl_datahub_cloud-0.3.12.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,258 @@
1
+ from datetime import datetime
2
+ from typing import Optional, Union
3
+
4
+ from acryl_datahub_cloud.sdk.assertion_input.assertion_input import (
5
+ DEFAULT_DAILY_SCHEDULE,
6
+ HIGH_WATERMARK_ALLOWED_FIELD_TYPES,
7
+ LAST_MODIFIED_ALLOWED_FIELD_TYPES,
8
+ AssertionIncidentBehaviorInputTypes,
9
+ DetectionMechanismInputTypes,
10
+ FieldSpecType,
11
+ TimeWindowSizeInputTypes,
12
+ _AssertionInput,
13
+ _AuditLog,
14
+ _DataHubOperation,
15
+ _HasFreshnessFeatures,
16
+ _HighWatermarkColumn,
17
+ _InformationSchema,
18
+ _LastModifiedColumn,
19
+ _try_parse_and_validate_schema_classes_enum,
20
+ _try_parse_time_window_size,
21
+ )
22
+ from acryl_datahub_cloud.sdk.entities.assertion import (
23
+ AssertionInfoInputType,
24
+ TagsInputType,
25
+ )
26
+ from acryl_datahub_cloud.sdk.errors import (
27
+ SDKNotYetSupportedError,
28
+ SDKUsageError,
29
+ )
30
+ from datahub.metadata import schema_classes as models
31
+ from datahub.metadata.urns import AssertionUrn, CorpUserUrn, DatasetUrn
32
+ from datahub.sdk.entity_client import EntityClient
33
+
34
+
35
+ class _FreshnessAssertionInput(_AssertionInput, _HasFreshnessFeatures):
36
+ def _assertion_type(self) -> str:
37
+ """Get the assertion type."""
38
+ return models.AssertionTypeClass.FRESHNESS
39
+
40
+ def __init__(
41
+ self,
42
+ *,
43
+ # Required fields
44
+ dataset_urn: Union[str, DatasetUrn],
45
+ entity_client: EntityClient, # Needed to get the schema field spec for the detection mechanism if needed
46
+ urn: Optional[Union[str, AssertionUrn]] = None,
47
+ # Optional fields
48
+ display_name: Optional[str] = None,
49
+ enabled: bool = True,
50
+ schedule: Optional[Union[str, models.CronScheduleClass]] = None,
51
+ detection_mechanism: DetectionMechanismInputTypes = None,
52
+ incident_behavior: Optional[AssertionIncidentBehaviorInputTypes] = None,
53
+ tags: Optional[TagsInputType] = None,
54
+ created_by: Union[str, CorpUserUrn],
55
+ created_at: datetime,
56
+ updated_by: Union[str, CorpUserUrn],
57
+ updated_at: datetime,
58
+ freshness_schedule_check_type: Optional[
59
+ Union[str, models.FreshnessAssertionScheduleTypeClass]
60
+ ] = None,
61
+ lookback_window: Optional[TimeWindowSizeInputTypes] = None,
62
+ ):
63
+ _AssertionInput.__init__(
64
+ self,
65
+ dataset_urn=dataset_urn,
66
+ entity_client=entity_client,
67
+ urn=urn,
68
+ display_name=display_name,
69
+ enabled=enabled,
70
+ schedule=schedule,
71
+ detection_mechanism=detection_mechanism,
72
+ incident_behavior=incident_behavior,
73
+ tags=tags,
74
+ source_type=models.AssertionSourceTypeClass.NATIVE, # Native assertions are of type native, not inferred
75
+ created_by=created_by,
76
+ created_at=created_at,
77
+ updated_by=updated_by,
78
+ updated_at=updated_at,
79
+ )
80
+
81
+ self.freshness_schedule_check_type = (
82
+ _try_parse_and_validate_schema_classes_enum(
83
+ freshness_schedule_check_type
84
+ or models.FreshnessAssertionScheduleTypeClass.SINCE_THE_LAST_CHECK,
85
+ models.FreshnessAssertionScheduleTypeClass,
86
+ )
87
+ )
88
+ self.lookback_window = (
89
+ _try_parse_time_window_size(lookback_window) if lookback_window else None
90
+ )
91
+ if (
92
+ self.freshness_schedule_check_type
93
+ is models.FreshnessAssertionScheduleTypeClass.FIXED_INTERVAL
94
+ and lookback_window is None
95
+ ):
96
+ raise SDKUsageError(
97
+ "Fixed interval freshness assertions must have a lookback_window provided."
98
+ )
99
+ if (
100
+ self.freshness_schedule_check_type
101
+ is models.FreshnessAssertionScheduleTypeClass.SINCE_THE_LAST_CHECK
102
+ and lookback_window is not None
103
+ ):
104
+ raise SDKUsageError(
105
+ "Since the last check freshness assertions cannot have a lookback_window provided."
106
+ )
107
+
108
+ def _create_monitor_info(
109
+ self,
110
+ assertion_urn: AssertionUrn,
111
+ status: models.MonitorStatusClass,
112
+ schedule: models.CronScheduleClass,
113
+ ) -> models.MonitorInfoClass:
114
+ """
115
+ Create a MonitorInfoClass with all the necessary components.
116
+ """
117
+ source_type, field = self._convert_assertion_source_type_and_field()
118
+ return models.MonitorInfoClass(
119
+ type=models.MonitorTypeClass.ASSERTION,
120
+ status=status,
121
+ assertionMonitor=models.AssertionMonitorClass(
122
+ assertions=[
123
+ models.AssertionEvaluationSpecClass(
124
+ assertion=str(assertion_urn),
125
+ schedule=schedule,
126
+ parameters=self._get_assertion_evaluation_parameters(
127
+ str(source_type), field
128
+ ),
129
+ )
130
+ ]
131
+ ),
132
+ )
133
+
134
+ def _create_assertion_info(
135
+ self, filter: Optional[models.DatasetFilterClass]
136
+ ) -> AssertionInfoInputType:
137
+ """
138
+ Create a FreshnessAssertionInfoClass for a freshness assertion.
139
+
140
+ Args:
141
+ filter: Optional filter to apply to the assertion. Only relevant for QUERY detection mechanism.
142
+
143
+ Returns:
144
+ A FreshnessAssertionInfoClass configured for freshness.
145
+ """
146
+ schedule = self._convert_schedule()
147
+ return models.FreshnessAssertionInfoClass(
148
+ type=models.FreshnessAssertionTypeClass.DATASET_CHANGE, # Currently only dataset change is supported
149
+ entity=str(self.dataset_urn),
150
+ schedule=models.FreshnessAssertionScheduleClass(
151
+ type=self.freshness_schedule_check_type
152
+ or models.FreshnessAssertionScheduleTypeClass.SINCE_THE_LAST_CHECK,
153
+ cron=models.FreshnessCronScheduleClass(
154
+ cron=schedule.cron,
155
+ timezone=schedule.timezone,
156
+ ),
157
+ fixedInterval=models.FixedIntervalScheduleClass(
158
+ multiple=self.lookback_window.multiple,
159
+ unit=self.lookback_window.unit,
160
+ )
161
+ if self.lookback_window
162
+ else None,
163
+ ),
164
+ filter=filter,
165
+ )
166
+
167
+ def _convert_schedule(self) -> models.CronScheduleClass:
168
+ """Create a schedule for a freshness assertion.
169
+
170
+ Returns:
171
+ A CronScheduleClass with appropriate schedule settings.
172
+ """
173
+ if self.schedule is None:
174
+ return DEFAULT_DAILY_SCHEDULE
175
+
176
+ return models.CronScheduleClass(
177
+ cron=self.schedule.cron,
178
+ timezone=self.schedule.timezone,
179
+ )
180
+
181
+ def _get_assertion_evaluation_parameters(
182
+ self, source_type: str, field: Optional[FieldSpecType]
183
+ ) -> models.AssertionEvaluationParametersClass:
184
+ # Ensure field is either None or FreshnessFieldSpecClass
185
+ freshness_field = None
186
+ if field is not None:
187
+ if not isinstance(field, models.FreshnessFieldSpecClass):
188
+ raise SDKUsageError(
189
+ f"Expected FreshnessFieldSpecClass for freshness assertion, got {type(field).__name__}"
190
+ )
191
+ freshness_field = field
192
+
193
+ return models.AssertionEvaluationParametersClass(
194
+ type=models.AssertionEvaluationParametersTypeClass.DATASET_FRESHNESS,
195
+ datasetFreshnessParameters=models.DatasetFreshnessAssertionParametersClass(
196
+ sourceType=source_type, field=freshness_field
197
+ ),
198
+ )
199
+
200
+ def _convert_assertion_source_type_and_field(
201
+ self,
202
+ ) -> tuple[str, Optional[FieldSpecType]]:
203
+ """
204
+ Convert detection mechanism into source type and field specification for freshness assertions.
205
+
206
+ Returns:
207
+ A tuple of (source_type, field) where field may be None.
208
+ Note that the source_type is a string, not a models.DatasetFreshnessSourceTypeClass (or other assertion source type) since
209
+ the source type is not a enum in the code generated from the DatasetFreshnessSourceType enum in the PDL.
210
+
211
+ Raises:
212
+ SDKNotYetSupportedError: If the detection mechanism is not supported.
213
+ SDKUsageError: If the field (column) is not found in the dataset,
214
+ and the detection mechanism requires a field. Also if the field
215
+ is not an allowed type for the detection mechanism.
216
+ """
217
+ source_type = models.DatasetFreshnessSourceTypeClass.INFORMATION_SCHEMA
218
+ field = None
219
+
220
+ if isinstance(self.detection_mechanism, _InformationSchema):
221
+ source_type = models.DatasetFreshnessSourceTypeClass.INFORMATION_SCHEMA
222
+ elif isinstance(self.detection_mechanism, _DataHubOperation):
223
+ source_type = models.DatasetFreshnessSourceTypeClass.DATAHUB_OPERATION
224
+ elif isinstance(self.detection_mechanism, _AuditLog):
225
+ source_type = models.DatasetFreshnessSourceTypeClass.AUDIT_LOG
226
+ elif isinstance(self.detection_mechanism, _LastModifiedColumn):
227
+ source_type = models.DatasetFreshnessSourceTypeClass.FIELD_VALUE
228
+ field = self._create_field_spec(
229
+ self.detection_mechanism.column_name,
230
+ LAST_MODIFIED_ALLOWED_FIELD_TYPES,
231
+ "last modified column",
232
+ models.FreshnessFieldKindClass.LAST_MODIFIED,
233
+ self._get_schema_field_spec,
234
+ self._validate_field_type,
235
+ )
236
+ elif isinstance(self.detection_mechanism, _HighWatermarkColumn):
237
+ if (
238
+ self.freshness_schedule_check_type
239
+ is models.FreshnessAssertionScheduleTypeClass.FIXED_INTERVAL
240
+ ):
241
+ raise SDKUsageError(
242
+ "Fixed interval freshness assertions cannot have a high watermark column provided."
243
+ )
244
+ source_type = models.DatasetFreshnessSourceTypeClass.FIELD_VALUE
245
+ field = self._create_field_spec(
246
+ self.detection_mechanism.column_name,
247
+ HIGH_WATERMARK_ALLOWED_FIELD_TYPES,
248
+ "high watermark column",
249
+ models.FreshnessFieldKindClass.HIGH_WATERMARK,
250
+ self._get_schema_field_spec,
251
+ self._validate_field_type,
252
+ )
253
+ else:
254
+ raise SDKNotYetSupportedError(
255
+ f"Detection mechanism {self.detection_mechanism} not yet supported for freshness assertions"
256
+ )
257
+
258
+ return source_type, field