Skip to content

Commit

Permalink
Merge pull request #339 from DataRecce/feature/drc-490-bug-recce-summ…
Browse files Browse the repository at this point in the history
…ary-genarete-failed

[Bug] The recce summary would raise exception if node is excluded
  • Loading branch information
popcornylu authored Jun 12, 2024
2 parents 17a19dd + 38cdbb7 commit 1f2c62d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions recce/adapter/dbt_adapter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,6 @@ def get_lineage(self, base: Optional[bool] = False):

manifest_dict = manifest.to_dict()

parent_map = {k: v for k, v in manifest_dict['parent_map'].items() if not k.startswith('test.')}

nodes = {}

for node in manifest_dict['nodes'].values():
Expand Down Expand Up @@ -492,6 +490,8 @@ def get_lineage(self, base: Optional[bool] = False):
'config': semantic_models['config'],
}

nodeIds = nodes.keys()
parent_map = {k: v for k, v in manifest_dict['parent_map'].items() if k in nodeIds}
return dict(
parent_map=parent_map,
nodes=nodes,
Expand Down
12 changes: 10 additions & 2 deletions recce/summary.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from typing import List, Dict, Set, Union, Type, Optional
from uuid import UUID

Expand All @@ -18,6 +19,11 @@
REMOVE_COLOR = '#ff067e'


def _warn(msg):
# print to stderr
print(f"warning: {msg}", file=sys.stderr)


class Node:
id: str
name: str
Expand Down Expand Up @@ -219,9 +225,11 @@ def create_node(self, node_id: str, node_data: dict, data_from: str = 'base'):

def create_edge(self, parent_id: str, child_id: str, edge_from: str = 'base'):
if parent_id not in self.nodes:
raise ValueError(f'Parent node {parent_id} not found in graph')
_warn(f'Parent node {parent_id} not found in graph')
return
if child_id not in self.nodes:
raise ValueError(f'Child node {child_id} not found in graph')
_warn(f'Child node {child_id} not found in graph')
return

edge_id = f'{parent_id}-->{child_id}'
if edge_id in self.edges:
Expand Down

0 comments on commit 1f2c62d

Please sign in to comment.