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,446 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Optional, Union
|
|
6
|
+
|
|
7
|
+
from acryl_datahub_cloud.sdk.assertion.assertion_base import (
|
|
8
|
+
AssertionMode,
|
|
9
|
+
VolumeAssertion,
|
|
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
|
+
)
|
|
21
|
+
from acryl_datahub_cloud.sdk.assertion_input.volume_assertion_input import (
|
|
22
|
+
VolumeAssertionCondition,
|
|
23
|
+
VolumeAssertionCriteria,
|
|
24
|
+
VolumeAssertionDefinitionParameters,
|
|
25
|
+
_VolumeAssertionInput,
|
|
26
|
+
)
|
|
27
|
+
from acryl_datahub_cloud.sdk.entities.assertion import Assertion, TagsInputType
|
|
28
|
+
from acryl_datahub_cloud.sdk.entities.monitor import Monitor
|
|
29
|
+
from acryl_datahub_cloud.sdk.errors import SDKUsageError
|
|
30
|
+
from datahub.metadata import schema_classes as models
|
|
31
|
+
from datahub.metadata.urns import AssertionUrn, CorpUserUrn, DatasetUrn, MonitorUrn
|
|
32
|
+
|
|
33
|
+
if TYPE_CHECKING:
|
|
34
|
+
from datahub.sdk.main_client import DataHubClient
|
|
35
|
+
|
|
36
|
+
logger = logging.getLogger(__name__)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class VolumeAssertionClient:
|
|
40
|
+
"""Client for managing volume assertions."""
|
|
41
|
+
|
|
42
|
+
def __init__(self, client: "DataHubClient"):
|
|
43
|
+
self.client = client
|
|
44
|
+
|
|
45
|
+
def sync_volume_assertion(
|
|
46
|
+
self,
|
|
47
|
+
*,
|
|
48
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
49
|
+
urn: Optional[Union[str, AssertionUrn]] = None,
|
|
50
|
+
display_name: Optional[str] = None,
|
|
51
|
+
enabled: Optional[bool] = None,
|
|
52
|
+
detection_mechanism: DetectionMechanismInputTypes = None,
|
|
53
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes] = None,
|
|
54
|
+
tags: Optional[TagsInputType] = None,
|
|
55
|
+
updated_by: Optional[Union[str, CorpUserUrn]] = None,
|
|
56
|
+
schedule: Optional[Union[str, models.CronScheduleClass]] = None,
|
|
57
|
+
criteria_condition: Optional[Union[str, VolumeAssertionCondition]] = None,
|
|
58
|
+
criteria_parameters: Optional[VolumeAssertionDefinitionParameters] = None,
|
|
59
|
+
) -> VolumeAssertion:
|
|
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. Validate criteria parameters if any are provided
|
|
70
|
+
if (criteria_condition is not None or criteria_parameters is not None) and (
|
|
71
|
+
criteria_condition is None or criteria_parameters is None
|
|
72
|
+
):
|
|
73
|
+
raise SDKUsageError(
|
|
74
|
+
"When providing volume assertion criteria, both criteria_condition and criteria_parameters must be provided"
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# Assert the invariant: if criteria_condition is provided, criteria_parameters is also provided
|
|
78
|
+
assert criteria_condition is None or criteria_parameters is not None, (
|
|
79
|
+
"criteria fields already validated"
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# 2. Retrieve and merge the assertion input with any existing assertion and monitor entities,
|
|
83
|
+
# or build a new assertion input if the assertion does not exist:
|
|
84
|
+
assertion_input = self._retrieve_and_merge_native_volume_assertion_and_monitor(
|
|
85
|
+
dataset_urn=dataset_urn,
|
|
86
|
+
urn=urn,
|
|
87
|
+
display_name=display_name,
|
|
88
|
+
enabled=enabled,
|
|
89
|
+
detection_mechanism=detection_mechanism,
|
|
90
|
+
criteria_condition=criteria_condition,
|
|
91
|
+
criteria_parameters=criteria_parameters,
|
|
92
|
+
incident_behavior=incident_behavior,
|
|
93
|
+
tags=tags,
|
|
94
|
+
updated_by=updated_by,
|
|
95
|
+
now_utc=now_utc,
|
|
96
|
+
schedule=schedule,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# 3. Upsert the assertion and monitor entities:
|
|
100
|
+
assertion_entity, monitor_entity = (
|
|
101
|
+
assertion_input.to_assertion_and_monitor_entities()
|
|
102
|
+
)
|
|
103
|
+
# If assertion upsert fails, we won't try to upsert the monitor
|
|
104
|
+
self.client.entities.upsert(assertion_entity)
|
|
105
|
+
# 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)
|
|
106
|
+
# try:
|
|
107
|
+
self.client.entities.upsert(monitor_entity)
|
|
108
|
+
# except Exception as e:
|
|
109
|
+
# logger.error(f"Error upserting monitor: {e}")
|
|
110
|
+
# self.client.entities.delete(assertion_entity)
|
|
111
|
+
# raise e
|
|
112
|
+
return VolumeAssertion._from_entities(assertion_entity, monitor_entity)
|
|
113
|
+
|
|
114
|
+
def _create_new_assertion_input(
|
|
115
|
+
self,
|
|
116
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
117
|
+
urn: Optional[Union[str, AssertionUrn]],
|
|
118
|
+
display_name: Optional[str],
|
|
119
|
+
enabled: Optional[bool],
|
|
120
|
+
detection_mechanism: DetectionMechanismInputTypes,
|
|
121
|
+
criteria_condition: Union[str, VolumeAssertionCondition],
|
|
122
|
+
criteria_parameters: VolumeAssertionDefinitionParameters,
|
|
123
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
124
|
+
tags: Optional[TagsInputType],
|
|
125
|
+
updated_by: Union[str, CorpUserUrn],
|
|
126
|
+
now_utc: datetime,
|
|
127
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
128
|
+
) -> _VolumeAssertionInput:
|
|
129
|
+
"""Create a new volume assertion input with given criteria."""
|
|
130
|
+
criteria: dict[str, Any] = {
|
|
131
|
+
"condition": criteria_condition,
|
|
132
|
+
"parameters": criteria_parameters,
|
|
133
|
+
}
|
|
134
|
+
return _VolumeAssertionInput(
|
|
135
|
+
urn=urn,
|
|
136
|
+
entity_client=self.client.entities,
|
|
137
|
+
dataset_urn=dataset_urn,
|
|
138
|
+
display_name=display_name,
|
|
139
|
+
enabled=enabled if enabled is not None else True,
|
|
140
|
+
detection_mechanism=detection_mechanism,
|
|
141
|
+
incident_behavior=incident_behavior,
|
|
142
|
+
tags=tags,
|
|
143
|
+
created_by=updated_by,
|
|
144
|
+
created_at=now_utc,
|
|
145
|
+
updated_by=updated_by,
|
|
146
|
+
updated_at=now_utc,
|
|
147
|
+
schedule=schedule,
|
|
148
|
+
criteria=criteria,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
def _create_existing_assertion_from_entities(
|
|
152
|
+
self,
|
|
153
|
+
maybe_assertion_entity: Optional[Assertion],
|
|
154
|
+
maybe_monitor_entity: Optional[Monitor],
|
|
155
|
+
monitor_urn: MonitorUrn,
|
|
156
|
+
enabled: Optional[bool],
|
|
157
|
+
) -> Optional[VolumeAssertion]:
|
|
158
|
+
"""Create existing assertion object from entities, handling missing monitor case."""
|
|
159
|
+
if maybe_assertion_entity and maybe_monitor_entity:
|
|
160
|
+
return VolumeAssertion._from_entities(
|
|
161
|
+
maybe_assertion_entity, maybe_monitor_entity
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
if maybe_assertion_entity and not maybe_monitor_entity:
|
|
165
|
+
monitor_mode = (
|
|
166
|
+
"ACTIVE" if enabled else "INACTIVE" if enabled is not None else "ACTIVE"
|
|
167
|
+
)
|
|
168
|
+
return VolumeAssertion._from_entities(
|
|
169
|
+
maybe_assertion_entity,
|
|
170
|
+
Monitor(id=monitor_urn, info=("ASSERTION", monitor_mode)),
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
return None
|
|
174
|
+
|
|
175
|
+
def _retrieve_and_merge_native_volume_assertion_and_monitor(
|
|
176
|
+
self,
|
|
177
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
178
|
+
urn: Optional[Union[str, AssertionUrn]],
|
|
179
|
+
display_name: Optional[str],
|
|
180
|
+
enabled: Optional[bool],
|
|
181
|
+
detection_mechanism: DetectionMechanismInputTypes,
|
|
182
|
+
criteria_condition: Optional[Union[str, VolumeAssertionCondition]],
|
|
183
|
+
criteria_parameters: Optional[VolumeAssertionDefinitionParameters],
|
|
184
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
185
|
+
tags: Optional[TagsInputType],
|
|
186
|
+
updated_by: Union[str, CorpUserUrn],
|
|
187
|
+
now_utc: datetime,
|
|
188
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
189
|
+
) -> _VolumeAssertionInput:
|
|
190
|
+
use_backend_criteria = criteria_condition is None
|
|
191
|
+
|
|
192
|
+
# 1. If urn is not provided, build and return a new assertion input directly
|
|
193
|
+
if urn is None:
|
|
194
|
+
if use_backend_criteria:
|
|
195
|
+
raise SDKUsageError(
|
|
196
|
+
"Volume assertion criteria are required when creating a new assertion"
|
|
197
|
+
)
|
|
198
|
+
logger.info("URN is not set, building a new assertion input")
|
|
199
|
+
assert criteria_condition is not None and criteria_parameters is not None
|
|
200
|
+
return self._create_new_assertion_input(
|
|
201
|
+
dataset_urn,
|
|
202
|
+
None,
|
|
203
|
+
display_name,
|
|
204
|
+
enabled,
|
|
205
|
+
detection_mechanism,
|
|
206
|
+
criteria_condition,
|
|
207
|
+
criteria_parameters,
|
|
208
|
+
incident_behavior,
|
|
209
|
+
tags,
|
|
210
|
+
updated_by,
|
|
211
|
+
now_utc,
|
|
212
|
+
schedule,
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
# 2. Prepare temporary criteria for validation
|
|
216
|
+
if criteria_condition is not None:
|
|
217
|
+
temp_criteria: dict[str, Any] = {
|
|
218
|
+
"condition": criteria_condition,
|
|
219
|
+
"parameters": criteria_parameters,
|
|
220
|
+
}
|
|
221
|
+
else:
|
|
222
|
+
temp_criteria = {
|
|
223
|
+
"condition": VolumeAssertionCondition.ROW_COUNT_IS_GREATER_THAN_OR_EQUAL_TO,
|
|
224
|
+
"parameters": 0,
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
# 3. Build initial assertion input for validation
|
|
228
|
+
assertion_input = _VolumeAssertionInput(
|
|
229
|
+
urn=urn,
|
|
230
|
+
entity_client=self.client.entities,
|
|
231
|
+
dataset_urn=dataset_urn,
|
|
232
|
+
display_name=display_name,
|
|
233
|
+
detection_mechanism=detection_mechanism,
|
|
234
|
+
incident_behavior=incident_behavior,
|
|
235
|
+
tags=tags,
|
|
236
|
+
created_by=updated_by,
|
|
237
|
+
created_at=now_utc,
|
|
238
|
+
updated_by=updated_by,
|
|
239
|
+
updated_at=now_utc,
|
|
240
|
+
schedule=schedule,
|
|
241
|
+
criteria=temp_criteria,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
# 4. Retrieve any existing assertion and monitor entities
|
|
245
|
+
maybe_assertion_entity, monitor_urn, maybe_monitor_entity = (
|
|
246
|
+
self._retrieve_assertion_and_monitor(assertion_input)
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
# 5. If the assertion does not exist, build and return a new assertion input
|
|
250
|
+
if not maybe_assertion_entity:
|
|
251
|
+
if use_backend_criteria:
|
|
252
|
+
raise SDKUsageError(
|
|
253
|
+
f"Cannot sync assertion {urn}: no existing definition found in backend and no definition provided in request"
|
|
254
|
+
)
|
|
255
|
+
logger.info(
|
|
256
|
+
f"No existing assertion entity found for assertion urn {urn}, building a new assertion input"
|
|
257
|
+
)
|
|
258
|
+
assert criteria_condition is not None and criteria_parameters is not None
|
|
259
|
+
return self._create_new_assertion_input(
|
|
260
|
+
dataset_urn,
|
|
261
|
+
urn,
|
|
262
|
+
display_name,
|
|
263
|
+
enabled,
|
|
264
|
+
detection_mechanism,
|
|
265
|
+
criteria_condition,
|
|
266
|
+
criteria_parameters,
|
|
267
|
+
incident_behavior,
|
|
268
|
+
tags,
|
|
269
|
+
updated_by,
|
|
270
|
+
now_utc,
|
|
271
|
+
schedule,
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
# 6. Create existing assertion from entities
|
|
275
|
+
existing_assertion = self._create_existing_assertion_from_entities(
|
|
276
|
+
maybe_assertion_entity, maybe_monitor_entity, monitor_urn, enabled
|
|
277
|
+
)
|
|
278
|
+
assert existing_assertion is not None, (
|
|
279
|
+
"existing_assertion is guaranteed non-None after early return check"
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
# 7. Check for any issues e.g. different dataset urns
|
|
283
|
+
if (
|
|
284
|
+
existing_assertion
|
|
285
|
+
and hasattr(existing_assertion, "dataset_urn")
|
|
286
|
+
and existing_assertion.dataset_urn != assertion_input.dataset_urn
|
|
287
|
+
):
|
|
288
|
+
raise SDKUsageError(
|
|
289
|
+
f"Dataset URN mismatch, existing assertion: {existing_assertion.dataset_urn} != new assertion: {dataset_urn}"
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
# 8. Determine effective criteria
|
|
293
|
+
if use_backend_criteria:
|
|
294
|
+
backend_criteria = VolumeAssertionCriteria.from_assertion(
|
|
295
|
+
maybe_assertion_entity
|
|
296
|
+
)
|
|
297
|
+
assertion_input.criteria = backend_criteria
|
|
298
|
+
effective_criteria = backend_criteria
|
|
299
|
+
logger.info("Using criteria from backend assertion")
|
|
300
|
+
else:
|
|
301
|
+
effective_criteria = assertion_input.criteria
|
|
302
|
+
|
|
303
|
+
# 9. Merge the existing assertion with the validated input
|
|
304
|
+
merged_assertion_input = self._merge_volume_input(
|
|
305
|
+
dataset_urn=dataset_urn,
|
|
306
|
+
urn=urn,
|
|
307
|
+
display_name=display_name,
|
|
308
|
+
enabled=enabled,
|
|
309
|
+
detection_mechanism=detection_mechanism,
|
|
310
|
+
incident_behavior=incident_behavior,
|
|
311
|
+
tags=tags,
|
|
312
|
+
now_utc=now_utc,
|
|
313
|
+
assertion_input=assertion_input,
|
|
314
|
+
maybe_assertion_entity=maybe_assertion_entity,
|
|
315
|
+
maybe_monitor_entity=maybe_monitor_entity,
|
|
316
|
+
existing_assertion=existing_assertion,
|
|
317
|
+
schedule=schedule,
|
|
318
|
+
criteria=effective_criteria,
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
return merged_assertion_input
|
|
322
|
+
|
|
323
|
+
def _retrieve_assertion_and_monitor(
|
|
324
|
+
self,
|
|
325
|
+
assertion_input: _VolumeAssertionInput,
|
|
326
|
+
) -> tuple[Optional[Assertion], MonitorUrn, Optional[Monitor]]:
|
|
327
|
+
"""Retrieve the assertion and monitor entities from the DataHub instance.
|
|
328
|
+
|
|
329
|
+
Args:
|
|
330
|
+
assertion_input: The validated input to the function.
|
|
331
|
+
|
|
332
|
+
Returns:
|
|
333
|
+
The assertion and monitor entities.
|
|
334
|
+
"""
|
|
335
|
+
assert assertion_input.urn is not None, "URN is required"
|
|
336
|
+
return retrieve_assertion_and_monitor_by_urn(
|
|
337
|
+
self.client, assertion_input.urn, assertion_input.dataset_urn
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
def _merge_volume_input(
|
|
341
|
+
self,
|
|
342
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
343
|
+
urn: Union[str, AssertionUrn],
|
|
344
|
+
display_name: Optional[str],
|
|
345
|
+
enabled: Optional[bool],
|
|
346
|
+
detection_mechanism: DetectionMechanismInputTypes,
|
|
347
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
348
|
+
tags: Optional[TagsInputType],
|
|
349
|
+
now_utc: datetime,
|
|
350
|
+
assertion_input: _VolumeAssertionInput,
|
|
351
|
+
maybe_assertion_entity: Optional[Assertion],
|
|
352
|
+
maybe_monitor_entity: Optional[Monitor],
|
|
353
|
+
existing_assertion: VolumeAssertion,
|
|
354
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
355
|
+
criteria: Optional[VolumeAssertionCriteria],
|
|
356
|
+
) -> _VolumeAssertionInput:
|
|
357
|
+
"""Merge the input with the existing assertion and monitor entities.
|
|
358
|
+
|
|
359
|
+
Args:
|
|
360
|
+
dataset_urn: The urn of the dataset to be monitored.
|
|
361
|
+
urn: The urn of the assertion.
|
|
362
|
+
display_name: The display name of the assertion.
|
|
363
|
+
enabled: Whether the assertion is enabled.
|
|
364
|
+
detection_mechanism: The detection mechanism to be used for the assertion.
|
|
365
|
+
incident_behavior: The incident behavior to be applied to the assertion.
|
|
366
|
+
tags: The tags to be applied to the assertion.
|
|
367
|
+
now_utc: The current UTC time from when the function is called.
|
|
368
|
+
assertion_input: The validated input to the function.
|
|
369
|
+
maybe_assertion_entity: The existing assertion entity from the DataHub instance.
|
|
370
|
+
maybe_monitor_entity: The existing monitor entity from the DataHub instance.
|
|
371
|
+
existing_assertion: The existing assertion from the DataHub instance.
|
|
372
|
+
schedule: The schedule to be applied to the assertion.
|
|
373
|
+
definition: The volume assertion definition to be applied to the assertion.
|
|
374
|
+
|
|
375
|
+
Returns:
|
|
376
|
+
The merged assertion input.
|
|
377
|
+
"""
|
|
378
|
+
merged_assertion_input = _VolumeAssertionInput(
|
|
379
|
+
urn=urn,
|
|
380
|
+
entity_client=self.client.entities,
|
|
381
|
+
dataset_urn=dataset_urn,
|
|
382
|
+
display_name=_merge_field(
|
|
383
|
+
display_name,
|
|
384
|
+
"display_name",
|
|
385
|
+
assertion_input,
|
|
386
|
+
existing_assertion,
|
|
387
|
+
maybe_assertion_entity.description if maybe_assertion_entity else None,
|
|
388
|
+
),
|
|
389
|
+
enabled=_merge_field(
|
|
390
|
+
enabled,
|
|
391
|
+
"enabled",
|
|
392
|
+
assertion_input,
|
|
393
|
+
existing_assertion,
|
|
394
|
+
existing_assertion.mode == AssertionMode.ACTIVE
|
|
395
|
+
if existing_assertion
|
|
396
|
+
else None,
|
|
397
|
+
),
|
|
398
|
+
schedule=_merge_field(
|
|
399
|
+
schedule,
|
|
400
|
+
"schedule",
|
|
401
|
+
assertion_input,
|
|
402
|
+
existing_assertion,
|
|
403
|
+
existing_assertion.schedule if existing_assertion else None,
|
|
404
|
+
),
|
|
405
|
+
detection_mechanism=_merge_field(
|
|
406
|
+
detection_mechanism,
|
|
407
|
+
"detection_mechanism",
|
|
408
|
+
assertion_input,
|
|
409
|
+
existing_assertion,
|
|
410
|
+
VolumeAssertion._get_detection_mechanism(
|
|
411
|
+
maybe_assertion_entity, maybe_monitor_entity, default=None
|
|
412
|
+
)
|
|
413
|
+
if maybe_assertion_entity and maybe_monitor_entity
|
|
414
|
+
else None,
|
|
415
|
+
),
|
|
416
|
+
incident_behavior=_merge_field(
|
|
417
|
+
incident_behavior,
|
|
418
|
+
"incident_behavior",
|
|
419
|
+
assertion_input,
|
|
420
|
+
existing_assertion,
|
|
421
|
+
VolumeAssertion._get_incident_behavior(maybe_assertion_entity)
|
|
422
|
+
if maybe_assertion_entity
|
|
423
|
+
else None,
|
|
424
|
+
),
|
|
425
|
+
tags=_merge_field(
|
|
426
|
+
tags,
|
|
427
|
+
"tags",
|
|
428
|
+
assertion_input,
|
|
429
|
+
existing_assertion,
|
|
430
|
+
maybe_assertion_entity.tags if maybe_assertion_entity else None,
|
|
431
|
+
),
|
|
432
|
+
criteria=_merge_field(
|
|
433
|
+
criteria,
|
|
434
|
+
"criteria",
|
|
435
|
+
assertion_input,
|
|
436
|
+
existing_assertion,
|
|
437
|
+
existing_assertion.criteria if existing_assertion else None,
|
|
438
|
+
),
|
|
439
|
+
created_by=existing_assertion.created_by
|
|
440
|
+
or DEFAULT_CREATED_BY, # Override with the existing assertion's created_by or the default created_by if not set
|
|
441
|
+
created_at=existing_assertion.created_at
|
|
442
|
+
or now_utc, # Override with the existing assertion's created_at or now if not set
|
|
443
|
+
updated_by=assertion_input.updated_by, # Override with the input's updated_by
|
|
444
|
+
updated_at=assertion_input.updated_at, # Override with the input's updated_at (now)
|
|
445
|
+
)
|
|
446
|
+
return merged_assertion_input
|
|
File without changes
|