acryl-datahub-cloud 0.3.11rc0__py3-none-any.whl → 0.3.16.1rc0__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.
- acryl_datahub_cloud/_codegen_config.json +1 -1
- acryl_datahub_cloud/acryl_cs_issues/models.py +5 -3
- acryl_datahub_cloud/action_request/action_request_owner_source.py +36 -6
- acryl_datahub_cloud/datahub_forms_notifications/__init__.py +0 -0
- acryl_datahub_cloud/datahub_forms_notifications/forms_notifications_source.py +569 -0
- acryl_datahub_cloud/datahub_forms_notifications/get_feature_flag.gql +7 -0
- acryl_datahub_cloud/datahub_forms_notifications/get_search_results_total.gql +14 -0
- acryl_datahub_cloud/datahub_forms_notifications/query.py +17 -0
- acryl_datahub_cloud/datahub_forms_notifications/scroll_forms_for_notification.gql +29 -0
- acryl_datahub_cloud/datahub_forms_notifications/send_form_notification_request.gql +5 -0
- acryl_datahub_cloud/datahub_reporting/datahub_dataset.py +37 -13
- acryl_datahub_cloud/datahub_reporting/datahub_form_reporting.py +55 -24
- acryl_datahub_cloud/datahub_reporting/extract_graph.py +4 -3
- acryl_datahub_cloud/datahub_reporting/extract_sql.py +242 -51
- acryl_datahub_cloud/datahub_reporting/forms.py +1 -1
- acryl_datahub_cloud/datahub_reporting/forms_config.py +3 -2
- acryl_datahub_cloud/datahub_restore/source.py +3 -2
- acryl_datahub_cloud/datahub_usage_reporting/excluded.py +94 -0
- acryl_datahub_cloud/datahub_usage_reporting/query_builder.py +48 -8
- acryl_datahub_cloud/datahub_usage_reporting/usage_feature_reporter.py +518 -77
- acryl_datahub_cloud/elasticsearch/graph_service.py +76 -14
- acryl_datahub_cloud/graphql_utils.py +64 -0
- acryl_datahub_cloud/lineage_features/source.py +555 -49
- acryl_datahub_cloud/metadata/_urns/urn_defs.py +2296 -1900
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/actionworkflow/__init__.py +53 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/anomaly/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/application/__init__.py +19 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/assertion/__init__.py +4 -2
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/common/__init__.py +6 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/conversation/__init__.py +29 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/event/notification/settings/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/execution/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/file/__init__.py +19 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/form/__init__.py +8 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/identity/__init__.py +8 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/knowledge/__init__.py +33 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/logical/__init__.py +15 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/metadata/key/__init__.py +12 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/metadata/search/features/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/module/__init__.py +31 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/notification/__init__.py +19 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/platform/event/v1/__init__.py +4 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/role/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/settings/asset/__init__.py +19 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/settings/global/__init__.py +28 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/template/__init__.py +31 -0
- acryl_datahub_cloud/metadata/schema.avsc +25091 -20557
- acryl_datahub_cloud/metadata/schema_classes.py +29269 -23863
- acryl_datahub_cloud/metadata/schemas/ActionRequestInfo.avsc +235 -2
- acryl_datahub_cloud/metadata/schemas/ActionWorkflowInfo.avsc +683 -0
- acryl_datahub_cloud/metadata/schemas/ActionWorkflowKey.avsc +21 -0
- acryl_datahub_cloud/metadata/schemas/Actors.avsc +38 -1
- acryl_datahub_cloud/metadata/schemas/ApplicationKey.avsc +31 -0
- acryl_datahub_cloud/metadata/schemas/ApplicationProperties.avsc +75 -0
- acryl_datahub_cloud/metadata/schemas/Applications.avsc +38 -0
- acryl_datahub_cloud/metadata/schemas/AssertionAnalyticsRunEvent.avsc +353 -215
- acryl_datahub_cloud/metadata/schemas/AssertionInfo.avsc +147 -20
- acryl_datahub_cloud/metadata/schemas/AssertionKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/AssertionRunEvent.avsc +166 -21
- acryl_datahub_cloud/metadata/schemas/{AssertionSummary.avsc → AssertionRunSummary.avsc} +15 -2
- acryl_datahub_cloud/metadata/schemas/AssertionsSummary.avsc +54 -0
- acryl_datahub_cloud/metadata/schemas/AssetSettings.avsc +63 -0
- acryl_datahub_cloud/metadata/schemas/BusinessAttributeInfo.avsc +7 -3
- acryl_datahub_cloud/metadata/schemas/ChartInfo.avsc +20 -6
- acryl_datahub_cloud/metadata/schemas/ChartKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/ConstraintInfo.avsc +12 -1
- acryl_datahub_cloud/metadata/schemas/ContainerKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/ContainerProperties.avsc +16 -5
- acryl_datahub_cloud/metadata/schemas/CorpGroupEditableInfo.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/CorpGroupInfo.avsc +7 -3
- acryl_datahub_cloud/metadata/schemas/CorpGroupKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/CorpGroupSettings.avsc +127 -2
- acryl_datahub_cloud/metadata/schemas/CorpUserEditableInfo.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/CorpUserInfo.avsc +18 -2
- acryl_datahub_cloud/metadata/schemas/CorpUserInvitationStatus.avsc +106 -0
- acryl_datahub_cloud/metadata/schemas/CorpUserKey.avsc +4 -1
- acryl_datahub_cloud/metadata/schemas/CorpUserSettings.avsc +304 -2
- acryl_datahub_cloud/metadata/schemas/CorpUserUsageFeatures.avsc +86 -0
- acryl_datahub_cloud/metadata/schemas/DashboardInfo.avsc +11 -5
- acryl_datahub_cloud/metadata/schemas/DashboardKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/DataFlowInfo.avsc +15 -5
- acryl_datahub_cloud/metadata/schemas/DataFlowKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/DataHubAiConversationInfo.avsc +256 -0
- acryl_datahub_cloud/metadata/schemas/DataHubAiConversationKey.avsc +22 -0
- acryl_datahub_cloud/metadata/schemas/DataHubFileInfo.avsc +234 -0
- acryl_datahub_cloud/metadata/schemas/DataHubFileKey.avsc +22 -0
- acryl_datahub_cloud/metadata/schemas/DataHubIngestionSourceKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/DataHubPageModuleKey.avsc +21 -0
- acryl_datahub_cloud/metadata/schemas/DataHubPageModuleProperties.avsc +308 -0
- acryl_datahub_cloud/metadata/schemas/DataHubPageTemplateKey.avsc +21 -0
- acryl_datahub_cloud/metadata/schemas/DataHubPageTemplateProperties.avsc +251 -0
- acryl_datahub_cloud/metadata/schemas/DataHubPolicyInfo.avsc +12 -1
- acryl_datahub_cloud/metadata/schemas/DataJobInfo.avsc +13 -4
- acryl_datahub_cloud/metadata/schemas/DataJobInputOutput.avsc +8 -0
- acryl_datahub_cloud/metadata/schemas/DataJobKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/DataPlatformInfo.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/DataPlatformInstanceProperties.avsc +5 -2
- acryl_datahub_cloud/metadata/schemas/DataProcessKey.avsc +4 -0
- acryl_datahub_cloud/metadata/schemas/DataProductKey.avsc +2 -0
- acryl_datahub_cloud/metadata/schemas/DataProductProperties.avsc +6 -3
- acryl_datahub_cloud/metadata/schemas/DataTypeInfo.avsc +5 -0
- acryl_datahub_cloud/metadata/schemas/DatasetKey.avsc +10 -2
- acryl_datahub_cloud/metadata/schemas/DatasetProperties.avsc +12 -5
- acryl_datahub_cloud/metadata/schemas/DatasetUsageStatistics.avsc +8 -0
- acryl_datahub_cloud/metadata/schemas/DocumentInfo.avsc +407 -0
- acryl_datahub_cloud/metadata/schemas/DocumentKey.avsc +35 -0
- acryl_datahub_cloud/metadata/schemas/DocumentSettings.avsc +79 -0
- acryl_datahub_cloud/metadata/schemas/DomainKey.avsc +2 -0
- acryl_datahub_cloud/metadata/schemas/DomainProperties.avsc +7 -3
- acryl_datahub_cloud/metadata/schemas/EditableContainerProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableDashboardProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableDataFlowProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableDataJobProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableDatasetProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableERModelRelationshipProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableMLFeatureProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableMLFeatureTableProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableMLModelGroupProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableMLModelProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableNotebookProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableSchemaMetadata.avsc +4 -2
- acryl_datahub_cloud/metadata/schemas/EntityTypeInfo.avsc +5 -0
- acryl_datahub_cloud/metadata/schemas/ExecutionRequestArtifactsLocation.avsc +16 -0
- acryl_datahub_cloud/metadata/schemas/ExecutionRequestKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/FormAssignmentStatus.avsc +36 -0
- acryl_datahub_cloud/metadata/schemas/FormInfo.avsc +6 -0
- acryl_datahub_cloud/metadata/schemas/FormKey.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/FormNotifications.avsc +69 -0
- acryl_datahub_cloud/metadata/schemas/FormSettings.avsc +30 -0
- acryl_datahub_cloud/metadata/schemas/GlobalSettingsInfo.avsc +416 -0
- acryl_datahub_cloud/metadata/schemas/GlobalTags.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/GlossaryNodeInfo.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/GlossaryNodeKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/GlossaryTermInfo.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/GlossaryTermKey.avsc +2 -0
- acryl_datahub_cloud/metadata/schemas/IcebergWarehouseInfo.avsc +4 -0
- acryl_datahub_cloud/metadata/schemas/IncidentActivityEvent.avsc +3 -3
- acryl_datahub_cloud/metadata/schemas/IncidentInfo.avsc +3 -3
- acryl_datahub_cloud/metadata/schemas/InferredMetadata.avsc +71 -1
- acryl_datahub_cloud/metadata/schemas/InputFields.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/InviteToken.avsc +26 -0
- acryl_datahub_cloud/metadata/schemas/LineageFeatures.avsc +67 -42
- acryl_datahub_cloud/metadata/schemas/LogicalParent.avsc +145 -0
- acryl_datahub_cloud/metadata/schemas/MLFeatureKey.avsc +4 -1
- acryl_datahub_cloud/metadata/schemas/MLFeatureTableKey.avsc +4 -1
- acryl_datahub_cloud/metadata/schemas/MLModelDeploymentKey.avsc +7 -1
- acryl_datahub_cloud/metadata/schemas/MLModelGroupKey.avsc +9 -1
- acryl_datahub_cloud/metadata/schemas/MLModelKey.avsc +9 -1
- acryl_datahub_cloud/metadata/schemas/MLModelProperties.avsc +4 -2
- acryl_datahub_cloud/metadata/schemas/MLPrimaryKeyKey.avsc +4 -1
- acryl_datahub_cloud/metadata/schemas/MetadataChangeEvent.avsc +418 -97
- acryl_datahub_cloud/metadata/schemas/MetadataChangeLog.avsc +62 -44
- acryl_datahub_cloud/metadata/schemas/MetadataChangeProposal.avsc +61 -0
- acryl_datahub_cloud/metadata/schemas/MonitorAnomalyEvent.avsc +54 -9
- acryl_datahub_cloud/metadata/schemas/MonitorInfo.avsc +163 -23
- acryl_datahub_cloud/metadata/schemas/MonitorKey.avsc +9 -1
- acryl_datahub_cloud/metadata/schemas/MonitorSuiteInfo.avsc +128 -3
- acryl_datahub_cloud/metadata/schemas/NotebookInfo.avsc +5 -2
- acryl_datahub_cloud/metadata/schemas/NotebookKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/NotificationRequest.avsc +91 -4
- acryl_datahub_cloud/metadata/schemas/Operation.avsc +17 -0
- acryl_datahub_cloud/metadata/schemas/Ownership.avsc +71 -1
- acryl_datahub_cloud/metadata/schemas/QuerySubjects.avsc +2 -13
- acryl_datahub_cloud/metadata/schemas/RelationshipChangeEvent.avsc +215 -0
- acryl_datahub_cloud/metadata/schemas/RoleProperties.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/SchemaFieldInfo.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/SchemaFieldKey.avsc +3 -0
- acryl_datahub_cloud/metadata/schemas/SchemaMetadata.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/SemanticContent.avsc +123 -0
- acryl_datahub_cloud/metadata/schemas/StructuredProperties.avsc +69 -0
- acryl_datahub_cloud/metadata/schemas/StructuredPropertyDefinition.avsc +15 -4
- acryl_datahub_cloud/metadata/schemas/StructuredPropertySettings.avsc +9 -0
- acryl_datahub_cloud/metadata/schemas/SubscriptionInfo.avsc +136 -5
- acryl_datahub_cloud/metadata/schemas/SubscriptionKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/SystemMetadata.avsc +61 -0
- acryl_datahub_cloud/metadata/schemas/TagProperties.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/TestInfo.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/UpstreamLineage.avsc +9 -0
- acryl_datahub_cloud/metadata/schemas/UsageFeatures.avsc +10 -0
- acryl_datahub_cloud/notifications/__init__.py +0 -0
- acryl_datahub_cloud/notifications/notification_recipient_builder.py +399 -0
- acryl_datahub_cloud/sdk/__init__.py +69 -0
- acryl_datahub_cloud/sdk/assertion/__init__.py +58 -0
- acryl_datahub_cloud/sdk/assertion/assertion_base.py +779 -0
- acryl_datahub_cloud/sdk/assertion/column_metric_assertion.py +191 -0
- acryl_datahub_cloud/sdk/assertion/column_value_assertion.py +431 -0
- acryl_datahub_cloud/sdk/assertion/freshness_assertion.py +201 -0
- acryl_datahub_cloud/sdk/assertion/schema_assertion.py +268 -0
- acryl_datahub_cloud/sdk/assertion/smart_column_metric_assertion.py +212 -0
- acryl_datahub_cloud/sdk/assertion/smart_freshness_assertion.py +165 -0
- acryl_datahub_cloud/sdk/assertion/smart_sql_assertion.py +156 -0
- acryl_datahub_cloud/sdk/assertion/smart_volume_assertion.py +162 -0
- acryl_datahub_cloud/sdk/assertion/sql_assertion.py +273 -0
- acryl_datahub_cloud/sdk/assertion/types.py +20 -0
- acryl_datahub_cloud/sdk/assertion/volume_assertion.py +156 -0
- acryl_datahub_cloud/sdk/assertion_client/__init__.py +0 -0
- acryl_datahub_cloud/sdk/assertion_client/column_metric.py +545 -0
- acryl_datahub_cloud/sdk/assertion_client/column_value.py +617 -0
- acryl_datahub_cloud/sdk/assertion_client/freshness.py +371 -0
- acryl_datahub_cloud/sdk/assertion_client/helpers.py +166 -0
- acryl_datahub_cloud/sdk/assertion_client/schema.py +358 -0
- acryl_datahub_cloud/sdk/assertion_client/smart_column_metric.py +540 -0
- acryl_datahub_cloud/sdk/assertion_client/smart_freshness.py +373 -0
- acryl_datahub_cloud/sdk/assertion_client/smart_sql.py +411 -0
- acryl_datahub_cloud/sdk/assertion_client/smart_volume.py +380 -0
- acryl_datahub_cloud/sdk/assertion_client/sql.py +410 -0
- acryl_datahub_cloud/sdk/assertion_client/volume.py +446 -0
- acryl_datahub_cloud/sdk/assertion_input/__init__.py +0 -0
- acryl_datahub_cloud/sdk/assertion_input/assertion_input.py +1470 -0
- acryl_datahub_cloud/sdk/assertion_input/column_assertion_constants.py +114 -0
- acryl_datahub_cloud/sdk/assertion_input/column_assertion_utils.py +284 -0
- acryl_datahub_cloud/sdk/assertion_input/column_metric_assertion_input.py +759 -0
- acryl_datahub_cloud/sdk/assertion_input/column_metric_constants.py +109 -0
- acryl_datahub_cloud/sdk/assertion_input/column_value_assertion_input.py +810 -0
- acryl_datahub_cloud/sdk/assertion_input/freshness_assertion_input.py +305 -0
- acryl_datahub_cloud/sdk/assertion_input/schema_assertion_input.py +413 -0
- acryl_datahub_cloud/sdk/assertion_input/smart_column_metric_assertion_input.py +793 -0
- acryl_datahub_cloud/sdk/assertion_input/smart_freshness_assertion_input.py +218 -0
- acryl_datahub_cloud/sdk/assertion_input/smart_sql_assertion_input.py +181 -0
- acryl_datahub_cloud/sdk/assertion_input/smart_volume_assertion_input.py +189 -0
- acryl_datahub_cloud/sdk/assertion_input/sql_assertion_input.py +320 -0
- acryl_datahub_cloud/sdk/assertion_input/volume_assertion_input.py +635 -0
- acryl_datahub_cloud/sdk/assertions_client.py +1074 -0
- acryl_datahub_cloud/sdk/entities/__init__.py +0 -0
- acryl_datahub_cloud/sdk/entities/assertion.py +439 -0
- acryl_datahub_cloud/sdk/entities/monitor.py +291 -0
- acryl_datahub_cloud/sdk/entities/subscription.py +100 -0
- acryl_datahub_cloud/sdk/errors.py +34 -0
- acryl_datahub_cloud/sdk/resolver_client.py +42 -0
- acryl_datahub_cloud/sdk/subscription_client.py +737 -0
- {acryl_datahub_cloud-0.3.11rc0.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/METADATA +55 -49
- {acryl_datahub_cloud-0.3.11rc0.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/RECORD +235 -142
- {acryl_datahub_cloud-0.3.11rc0.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/WHEEL +1 -1
- {acryl_datahub_cloud-0.3.11rc0.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/entry_points.txt +1 -0
- acryl_datahub_cloud/_sdk_extras/__init__.py +0 -4
- acryl_datahub_cloud/_sdk_extras/assertion.py +0 -15
- acryl_datahub_cloud/_sdk_extras/assertions_client.py +0 -23
- {acryl_datahub_cloud-0.3.11rc0.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
from typing import TYPE_CHECKING, Optional, Union
|
|
6
|
+
|
|
7
|
+
from acryl_datahub_cloud.sdk.assertion.assertion_base import (
|
|
8
|
+
AssertionMode,
|
|
9
|
+
SmartVolumeAssertion,
|
|
10
|
+
)
|
|
11
|
+
from acryl_datahub_cloud.sdk.assertion_client.helpers import (
|
|
12
|
+
DEFAULT_CREATED_BY,
|
|
13
|
+
_merge_field,
|
|
14
|
+
_print_experimental_warning,
|
|
15
|
+
retrieve_assertion_and_monitor_by_urn,
|
|
16
|
+
)
|
|
17
|
+
from acryl_datahub_cloud.sdk.assertion_input.assertion_input import (
|
|
18
|
+
AssertionIncidentBehaviorInputTypes,
|
|
19
|
+
DetectionMechanismInputTypes,
|
|
20
|
+
ExclusionWindowInputTypes,
|
|
21
|
+
InferenceSensitivity,
|
|
22
|
+
)
|
|
23
|
+
from acryl_datahub_cloud.sdk.assertion_input.smart_volume_assertion_input import (
|
|
24
|
+
_SmartVolumeAssertionInput,
|
|
25
|
+
)
|
|
26
|
+
from acryl_datahub_cloud.sdk.entities.assertion import Assertion, TagsInputType
|
|
27
|
+
from acryl_datahub_cloud.sdk.entities.monitor import Monitor
|
|
28
|
+
from acryl_datahub_cloud.sdk.errors import SDKUsageError
|
|
29
|
+
from datahub.metadata import schema_classes as models
|
|
30
|
+
from datahub.metadata.urns import AssertionUrn, CorpUserUrn, DatasetUrn, MonitorUrn
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from datahub.sdk.main_client import DataHubClient
|
|
34
|
+
|
|
35
|
+
logger = logging.getLogger(__name__)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class SmartVolumeAssertionClient:
|
|
39
|
+
"""Client for managing smart volume assertions."""
|
|
40
|
+
|
|
41
|
+
def __init__(self, client: "DataHubClient"):
|
|
42
|
+
self.client = client
|
|
43
|
+
|
|
44
|
+
def sync_smart_volume_assertion(
|
|
45
|
+
self,
|
|
46
|
+
*,
|
|
47
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
48
|
+
urn: Optional[Union[str, AssertionUrn]] = None,
|
|
49
|
+
display_name: Optional[str] = None,
|
|
50
|
+
enabled: Optional[bool] = None,
|
|
51
|
+
detection_mechanism: DetectionMechanismInputTypes = None,
|
|
52
|
+
sensitivity: Optional[Union[str, InferenceSensitivity]] = None,
|
|
53
|
+
exclusion_windows: Optional[ExclusionWindowInputTypes] = None,
|
|
54
|
+
training_data_lookback_days: Optional[int] = None,
|
|
55
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes] = None,
|
|
56
|
+
tags: Optional[TagsInputType] = None,
|
|
57
|
+
updated_by: Optional[Union[str, CorpUserUrn]] = None,
|
|
58
|
+
schedule: Optional[Union[str, models.CronScheduleClass]] = None,
|
|
59
|
+
) -> SmartVolumeAssertion:
|
|
60
|
+
_print_experimental_warning()
|
|
61
|
+
now_utc = datetime.now(timezone.utc)
|
|
62
|
+
|
|
63
|
+
if updated_by is None:
|
|
64
|
+
logger.warning(
|
|
65
|
+
f"updated_by is not set, using {DEFAULT_CREATED_BY} as a placeholder"
|
|
66
|
+
)
|
|
67
|
+
updated_by = DEFAULT_CREATED_BY
|
|
68
|
+
|
|
69
|
+
# 1. Retrieve and merge the assertion input with any existing assertion and monitor entities,
|
|
70
|
+
# or build a new assertion input if the assertion does not exist:
|
|
71
|
+
assertion_input = self._retrieve_and_merge_volume_assertion_and_monitor(
|
|
72
|
+
dataset_urn=dataset_urn,
|
|
73
|
+
urn=urn,
|
|
74
|
+
display_name=display_name,
|
|
75
|
+
enabled=enabled,
|
|
76
|
+
detection_mechanism=detection_mechanism,
|
|
77
|
+
sensitivity=sensitivity,
|
|
78
|
+
exclusion_windows=exclusion_windows,
|
|
79
|
+
training_data_lookback_days=training_data_lookback_days,
|
|
80
|
+
incident_behavior=incident_behavior,
|
|
81
|
+
tags=tags,
|
|
82
|
+
updated_by=updated_by,
|
|
83
|
+
now_utc=now_utc,
|
|
84
|
+
schedule=schedule,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# 2. Upsert the assertion and monitor entities:
|
|
88
|
+
assertion_entity, monitor_entity = (
|
|
89
|
+
assertion_input.to_assertion_and_monitor_entities()
|
|
90
|
+
)
|
|
91
|
+
# If assertion upsert fails, we won't try to upsert the monitor
|
|
92
|
+
self.client.entities.upsert(assertion_entity)
|
|
93
|
+
# TODO: Wrap monitor upsert in a try-except and delete the assertion if monitor upsert fails (once delete is implemented https://linear.app/acryl-data/issue/OBS-1350/add-delete-method-to-entity-clientpy)
|
|
94
|
+
# try:
|
|
95
|
+
self.client.entities.upsert(monitor_entity)
|
|
96
|
+
# except Exception as e:
|
|
97
|
+
# logger.error(f"Error upserting monitor: {e}")
|
|
98
|
+
# self.client.entities.delete(assertion_entity)
|
|
99
|
+
# raise e
|
|
100
|
+
|
|
101
|
+
return SmartVolumeAssertion._from_entities(assertion_entity, monitor_entity)
|
|
102
|
+
|
|
103
|
+
def _retrieve_and_merge_volume_assertion_and_monitor(
|
|
104
|
+
self,
|
|
105
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
106
|
+
urn: Optional[Union[str, AssertionUrn]],
|
|
107
|
+
display_name: Optional[str],
|
|
108
|
+
enabled: Optional[bool],
|
|
109
|
+
detection_mechanism: DetectionMechanismInputTypes,
|
|
110
|
+
sensitivity: Optional[Union[str, InferenceSensitivity]],
|
|
111
|
+
exclusion_windows: Optional[ExclusionWindowInputTypes],
|
|
112
|
+
training_data_lookback_days: Optional[int],
|
|
113
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
114
|
+
tags: Optional[TagsInputType],
|
|
115
|
+
updated_by: Union[str, CorpUserUrn],
|
|
116
|
+
now_utc: datetime,
|
|
117
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
118
|
+
) -> _SmartVolumeAssertionInput:
|
|
119
|
+
# 1. If urn is not provided, build and return a new assertion input directly
|
|
120
|
+
if urn is None:
|
|
121
|
+
logger.info("URN is not set, building a new assertion input")
|
|
122
|
+
return _SmartVolumeAssertionInput(
|
|
123
|
+
urn=None,
|
|
124
|
+
entity_client=self.client.entities,
|
|
125
|
+
dataset_urn=dataset_urn,
|
|
126
|
+
display_name=display_name,
|
|
127
|
+
enabled=enabled if enabled is not None else True,
|
|
128
|
+
detection_mechanism=detection_mechanism,
|
|
129
|
+
sensitivity=sensitivity,
|
|
130
|
+
exclusion_windows=exclusion_windows,
|
|
131
|
+
training_data_lookback_days=training_data_lookback_days,
|
|
132
|
+
incident_behavior=incident_behavior,
|
|
133
|
+
tags=tags,
|
|
134
|
+
created_by=updated_by,
|
|
135
|
+
created_at=now_utc,
|
|
136
|
+
updated_by=updated_by,
|
|
137
|
+
updated_at=now_utc,
|
|
138
|
+
schedule=schedule,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# 2. Build initial assertion input for validation
|
|
142
|
+
assertion_input = _SmartVolumeAssertionInput(
|
|
143
|
+
urn=urn,
|
|
144
|
+
entity_client=self.client.entities,
|
|
145
|
+
dataset_urn=dataset_urn,
|
|
146
|
+
display_name=display_name,
|
|
147
|
+
detection_mechanism=detection_mechanism,
|
|
148
|
+
sensitivity=sensitivity,
|
|
149
|
+
exclusion_windows=exclusion_windows,
|
|
150
|
+
training_data_lookback_days=training_data_lookback_days,
|
|
151
|
+
incident_behavior=incident_behavior,
|
|
152
|
+
tags=tags,
|
|
153
|
+
created_by=updated_by, # This will be overridden by the actual created_by
|
|
154
|
+
created_at=now_utc, # This will be overridden by the actual created_at
|
|
155
|
+
updated_by=updated_by,
|
|
156
|
+
updated_at=now_utc,
|
|
157
|
+
schedule=schedule,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
# 3. Retrieve any existing assertion and monitor entities:
|
|
161
|
+
maybe_assertion_entity, monitor_urn, maybe_monitor_entity = (
|
|
162
|
+
self._retrieve_assertion_and_monitor(assertion_input)
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
# 4.1 If the assertion and monitor entities exist, create an assertion object from them:
|
|
166
|
+
if maybe_assertion_entity and maybe_monitor_entity:
|
|
167
|
+
existing_assertion = SmartVolumeAssertion._from_entities(
|
|
168
|
+
maybe_assertion_entity, maybe_monitor_entity
|
|
169
|
+
)
|
|
170
|
+
# 4.2 If the assertion exists but the monitor does not, create a placeholder monitor entity to be able to create the assertion:
|
|
171
|
+
elif maybe_assertion_entity and not maybe_monitor_entity:
|
|
172
|
+
monitor_mode = (
|
|
173
|
+
"ACTIVE" if enabled else "INACTIVE" if enabled is not None else "ACTIVE"
|
|
174
|
+
)
|
|
175
|
+
existing_assertion = SmartVolumeAssertion._from_entities(
|
|
176
|
+
maybe_assertion_entity,
|
|
177
|
+
Monitor(id=monitor_urn, info=("ASSERTION", monitor_mode)),
|
|
178
|
+
)
|
|
179
|
+
# 4.3 If the assertion does not exist, build and return a new assertion input:
|
|
180
|
+
elif not maybe_assertion_entity:
|
|
181
|
+
logger.info(
|
|
182
|
+
f"No existing assertion entity found for assertion urn {urn}, building a new assertion input"
|
|
183
|
+
)
|
|
184
|
+
return _SmartVolumeAssertionInput(
|
|
185
|
+
urn=urn,
|
|
186
|
+
entity_client=self.client.entities,
|
|
187
|
+
dataset_urn=dataset_urn,
|
|
188
|
+
display_name=display_name,
|
|
189
|
+
enabled=enabled if enabled is not None else True,
|
|
190
|
+
detection_mechanism=detection_mechanism,
|
|
191
|
+
sensitivity=sensitivity,
|
|
192
|
+
exclusion_windows=exclusion_windows,
|
|
193
|
+
training_data_lookback_days=training_data_lookback_days,
|
|
194
|
+
incident_behavior=incident_behavior,
|
|
195
|
+
tags=tags,
|
|
196
|
+
created_by=updated_by,
|
|
197
|
+
created_at=now_utc,
|
|
198
|
+
updated_by=updated_by,
|
|
199
|
+
updated_at=now_utc,
|
|
200
|
+
schedule=schedule,
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
# 5. Check for any issues e.g. different dataset urns
|
|
204
|
+
if (
|
|
205
|
+
existing_assertion
|
|
206
|
+
and hasattr(existing_assertion, "dataset_urn")
|
|
207
|
+
and existing_assertion.dataset_urn != assertion_input.dataset_urn
|
|
208
|
+
):
|
|
209
|
+
raise SDKUsageError(
|
|
210
|
+
f"Dataset URN mismatch, existing assertion: {existing_assertion.dataset_urn} != new assertion: {dataset_urn}"
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
# 6. Merge the existing assertion with the validated input:
|
|
214
|
+
merged_assertion_input = self._merge_smart_volume_input(
|
|
215
|
+
dataset_urn=dataset_urn,
|
|
216
|
+
urn=urn,
|
|
217
|
+
display_name=display_name,
|
|
218
|
+
enabled=enabled,
|
|
219
|
+
detection_mechanism=detection_mechanism,
|
|
220
|
+
sensitivity=sensitivity,
|
|
221
|
+
exclusion_windows=exclusion_windows,
|
|
222
|
+
training_data_lookback_days=training_data_lookback_days,
|
|
223
|
+
incident_behavior=incident_behavior,
|
|
224
|
+
tags=tags,
|
|
225
|
+
schedule=schedule,
|
|
226
|
+
now_utc=now_utc,
|
|
227
|
+
assertion_input=assertion_input,
|
|
228
|
+
maybe_assertion_entity=maybe_assertion_entity,
|
|
229
|
+
maybe_monitor_entity=maybe_monitor_entity,
|
|
230
|
+
existing_assertion=existing_assertion,
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
return merged_assertion_input
|
|
234
|
+
|
|
235
|
+
def _retrieve_assertion_and_monitor(
|
|
236
|
+
self,
|
|
237
|
+
assertion_input: _SmartVolumeAssertionInput,
|
|
238
|
+
) -> tuple[Optional[Assertion], MonitorUrn, Optional[Monitor]]:
|
|
239
|
+
"""Retrieve the assertion and monitor entities from the DataHub instance.
|
|
240
|
+
|
|
241
|
+
Args:
|
|
242
|
+
assertion_input: The validated input to the function.
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
The assertion and monitor entities.
|
|
246
|
+
"""
|
|
247
|
+
assert assertion_input.urn is not None, "URN is required"
|
|
248
|
+
return retrieve_assertion_and_monitor_by_urn(
|
|
249
|
+
self.client, assertion_input.urn, assertion_input.dataset_urn
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
def _merge_smart_volume_input(
|
|
253
|
+
self,
|
|
254
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
255
|
+
urn: Union[str, AssertionUrn],
|
|
256
|
+
display_name: Optional[str],
|
|
257
|
+
enabled: Optional[bool],
|
|
258
|
+
detection_mechanism: DetectionMechanismInputTypes,
|
|
259
|
+
sensitivity: Optional[Union[str, InferenceSensitivity]],
|
|
260
|
+
exclusion_windows: Optional[ExclusionWindowInputTypes],
|
|
261
|
+
training_data_lookback_days: Optional[int],
|
|
262
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
263
|
+
tags: Optional[TagsInputType],
|
|
264
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
265
|
+
now_utc: datetime,
|
|
266
|
+
assertion_input: _SmartVolumeAssertionInput,
|
|
267
|
+
maybe_assertion_entity: Optional[Assertion],
|
|
268
|
+
maybe_monitor_entity: Optional[Monitor],
|
|
269
|
+
existing_assertion: SmartVolumeAssertion,
|
|
270
|
+
) -> _SmartVolumeAssertionInput:
|
|
271
|
+
"""Merge the input with the existing assertion and monitor entities.
|
|
272
|
+
|
|
273
|
+
Args:
|
|
274
|
+
dataset_urn: The urn of the dataset to be monitored.
|
|
275
|
+
urn: The urn of the assertion.
|
|
276
|
+
display_name: The display name of the assertion.
|
|
277
|
+
enabled: Whether the assertion is enabled.
|
|
278
|
+
detection_mechanism: The detection mechanism to be used for the assertion.
|
|
279
|
+
sensitivity: The sensitivity to be applied to the assertion.
|
|
280
|
+
exclusion_windows: The exclusion windows to be applied to the assertion.
|
|
281
|
+
training_data_lookback_days: The training data lookback days to be applied to the assertion.
|
|
282
|
+
incident_behavior: The incident behavior to be applied to the assertion.
|
|
283
|
+
tags: The tags to be applied to the assertion.
|
|
284
|
+
now_utc: The current UTC time from when the function is called.
|
|
285
|
+
assertion_input: The validated input to the function.
|
|
286
|
+
maybe_assertion_entity: The existing assertion entity from the DataHub instance.
|
|
287
|
+
maybe_monitor_entity: The existing monitor entity from the DataHub instance.
|
|
288
|
+
existing_assertion: The existing assertion from the DataHub instance.
|
|
289
|
+
|
|
290
|
+
Returns:
|
|
291
|
+
The merged assertion input.
|
|
292
|
+
"""
|
|
293
|
+
merged_assertion_input = _SmartVolumeAssertionInput(
|
|
294
|
+
urn=urn,
|
|
295
|
+
entity_client=self.client.entities,
|
|
296
|
+
dataset_urn=dataset_urn,
|
|
297
|
+
display_name=_merge_field(
|
|
298
|
+
display_name,
|
|
299
|
+
"display_name",
|
|
300
|
+
assertion_input,
|
|
301
|
+
existing_assertion,
|
|
302
|
+
maybe_assertion_entity.description if maybe_assertion_entity else None,
|
|
303
|
+
),
|
|
304
|
+
enabled=_merge_field(
|
|
305
|
+
enabled,
|
|
306
|
+
"enabled",
|
|
307
|
+
assertion_input,
|
|
308
|
+
existing_assertion,
|
|
309
|
+
existing_assertion.mode == AssertionMode.ACTIVE
|
|
310
|
+
if existing_assertion
|
|
311
|
+
else None,
|
|
312
|
+
),
|
|
313
|
+
schedule=_merge_field(
|
|
314
|
+
schedule,
|
|
315
|
+
"schedule",
|
|
316
|
+
assertion_input,
|
|
317
|
+
existing_assertion,
|
|
318
|
+
existing_assertion.schedule if existing_assertion else None,
|
|
319
|
+
),
|
|
320
|
+
detection_mechanism=_merge_field(
|
|
321
|
+
detection_mechanism,
|
|
322
|
+
"detection_mechanism",
|
|
323
|
+
assertion_input,
|
|
324
|
+
existing_assertion,
|
|
325
|
+
SmartVolumeAssertion._get_detection_mechanism(
|
|
326
|
+
maybe_assertion_entity, maybe_monitor_entity, default=None
|
|
327
|
+
)
|
|
328
|
+
if maybe_assertion_entity and maybe_monitor_entity
|
|
329
|
+
else None,
|
|
330
|
+
),
|
|
331
|
+
sensitivity=_merge_field(
|
|
332
|
+
sensitivity,
|
|
333
|
+
"sensitivity",
|
|
334
|
+
assertion_input,
|
|
335
|
+
existing_assertion,
|
|
336
|
+
maybe_monitor_entity.sensitivity if maybe_monitor_entity else None,
|
|
337
|
+
),
|
|
338
|
+
exclusion_windows=_merge_field(
|
|
339
|
+
exclusion_windows,
|
|
340
|
+
"exclusion_windows",
|
|
341
|
+
assertion_input,
|
|
342
|
+
existing_assertion,
|
|
343
|
+
maybe_monitor_entity.exclusion_windows
|
|
344
|
+
if maybe_monitor_entity
|
|
345
|
+
else None,
|
|
346
|
+
),
|
|
347
|
+
training_data_lookback_days=_merge_field(
|
|
348
|
+
training_data_lookback_days,
|
|
349
|
+
"training_data_lookback_days",
|
|
350
|
+
assertion_input,
|
|
351
|
+
existing_assertion,
|
|
352
|
+
maybe_monitor_entity.training_data_lookback_days
|
|
353
|
+
if maybe_monitor_entity
|
|
354
|
+
else None,
|
|
355
|
+
),
|
|
356
|
+
incident_behavior=_merge_field(
|
|
357
|
+
incident_behavior,
|
|
358
|
+
"incident_behavior",
|
|
359
|
+
assertion_input,
|
|
360
|
+
existing_assertion,
|
|
361
|
+
SmartVolumeAssertion._get_incident_behavior(maybe_assertion_entity)
|
|
362
|
+
if maybe_assertion_entity
|
|
363
|
+
else None,
|
|
364
|
+
),
|
|
365
|
+
tags=_merge_field(
|
|
366
|
+
tags,
|
|
367
|
+
"tags",
|
|
368
|
+
assertion_input,
|
|
369
|
+
existing_assertion,
|
|
370
|
+
maybe_assertion_entity.tags if maybe_assertion_entity else None,
|
|
371
|
+
),
|
|
372
|
+
created_by=existing_assertion.created_by
|
|
373
|
+
or DEFAULT_CREATED_BY, # Override with the existing assertion's created_by or the default created_by if not set
|
|
374
|
+
created_at=existing_assertion.created_at
|
|
375
|
+
or now_utc, # Override with the existing assertion's created_at or now if not set
|
|
376
|
+
updated_by=assertion_input.updated_by, # Override with the input's updated_by
|
|
377
|
+
updated_at=assertion_input.updated_at, # Override with the input's updated_at (now)
|
|
378
|
+
)
|
|
379
|
+
|
|
380
|
+
return merged_assertion_input
|