mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-15 19:03:43 +00:00
test(ingest/testing-utils): Add back delta info ignore path (#8402)
This commit is contained in:
parent
779d692cdc
commit
71f80b6207
@ -89,7 +89,7 @@ def diff_metadata_json(
|
|||||||
golden: MetadataJson,
|
golden: MetadataJson,
|
||||||
ignore_paths: Sequence[str] = (),
|
ignore_paths: Sequence[str] = (),
|
||||||
) -> Union[DeepDiff, MCPDiff]:
|
) -> Union[DeepDiff, MCPDiff]:
|
||||||
ignore_paths = (*ignore_paths, *default_exclude_paths)
|
ignore_paths = (*ignore_paths, *default_exclude_paths, r"root\[\d+].delta_info")
|
||||||
try:
|
try:
|
||||||
golden_map = get_aspects_by_urn(golden)
|
golden_map = get_aspects_by_urn(golden)
|
||||||
output_map = get_aspects_by_urn(output)
|
output_map = get_aspects_by_urn(output)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
|
import dataclasses
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from dataclasses import dataclass, field
|
|
||||||
from typing import Any, Dict, List, Sequence, Set, Tuple, Union
|
from typing import Any, Dict, List, Sequence, Set, Tuple, Union
|
||||||
|
|
||||||
import deepdiff.serialization
|
import deepdiff.serialization
|
||||||
@ -27,13 +28,13 @@ ReportType = Literal[
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclasses.dataclass(frozen=True)
|
||||||
class AspectForDiff:
|
class AspectForDiff:
|
||||||
urn: str
|
urn: str
|
||||||
change_type: str
|
change_type: str
|
||||||
aspect_name: str
|
aspect_name: str
|
||||||
aspect: Dict[str, Any] = field(hash=False)
|
aspect: Dict[str, Any] = dataclasses.field(hash=False)
|
||||||
delta_info: "DeltaInfo" = field(hash=False)
|
delta_info: "DeltaInfo" = dataclasses.field(hash=False, repr=False)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_from_mcp(cls, idx: int, obj: Dict[str, Any]) -> "AspectForDiff":
|
def create_from_mcp(cls, idx: int, obj: Dict[str, Any]) -> "AspectForDiff":
|
||||||
@ -46,8 +47,17 @@ class AspectForDiff:
|
|||||||
delta_info=DeltaInfo(idx=idx, original=obj),
|
delta_info=DeltaInfo(idx=idx, original=obj),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
d = {
|
||||||
|
field.name: getattr(self, field.name)
|
||||||
|
for field in dataclasses.fields(self)
|
||||||
|
if field.repr
|
||||||
|
}
|
||||||
|
d["aspect"] = "<aspect>"
|
||||||
|
return "\n" + "\t" * 2 + str(json.dumps(d))
|
||||||
|
|
||||||
@dataclass
|
|
||||||
|
@dataclasses.dataclass
|
||||||
class DeltaInfo:
|
class DeltaInfo:
|
||||||
"""Information about an MCP used to construct a diff delta.
|
"""Information about an MCP used to construct a diff delta.
|
||||||
|
|
||||||
@ -59,6 +69,10 @@ class DeltaInfo:
|
|||||||
|
|
||||||
|
|
||||||
class DeltaInfoOperator(BaseOperator):
|
class DeltaInfoOperator(BaseOperator):
|
||||||
|
"""Warning: Doesn't seem to be working right now.
|
||||||
|
Ignored via an ignore path as an extra layer of defense.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(types=[DeltaInfo])
|
super().__init__(types=[DeltaInfo])
|
||||||
|
|
||||||
@ -93,7 +107,7 @@ def get_aspects_by_urn(obj: object) -> AspectsByUrn:
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclasses.dataclass
|
||||||
class MCPAspectDiff:
|
class MCPAspectDiff:
|
||||||
aspects_added: Dict[int, AspectForDiff]
|
aspects_added: Dict[int, AspectForDiff]
|
||||||
aspects_removed: Dict[int, AspectForDiff]
|
aspects_removed: Dict[int, AspectForDiff]
|
||||||
@ -126,7 +140,7 @@ class MCPAspectDiff:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclasses.dataclass
|
||||||
class MCPDiff:
|
class MCPDiff:
|
||||||
aspect_changes: Dict[str, Dict[str, MCPAspectDiff]] # urn -> aspect -> diff
|
aspect_changes: Dict[str, Dict[str, MCPAspectDiff]] # urn -> aspect -> diff
|
||||||
urns_added: Set[str]
|
urns_added: Set[str]
|
||||||
@ -169,7 +183,7 @@ class MCPDiff:
|
|||||||
def convert_path(path: str) -> str:
|
def convert_path(path: str) -> str:
|
||||||
# Attempt to use paths intended for the root golden... sorry for the regex
|
# Attempt to use paths intended for the root golden... sorry for the regex
|
||||||
return re.sub(
|
return re.sub(
|
||||||
r"root\\?\[([0-9]+|\\d\+)\\?]\\?\['aspect'\\?](\\?\['(json|value)'\\?])?",
|
r"^root\\?\[([0-9]+|\\d\+)\\?]\\?\['aspect'\\?](\\?\['(json|value)'\\?])?",
|
||||||
r"root\[\\d+].aspect",
|
r"root\[\\d+].aspect",
|
||||||
path,
|
path,
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user