@@ -666,6 +666,7 @@ def to_datahub_dashboard_mcp(
666
666
workspace : powerbi_data_classes .Workspace ,
667
667
chart_mcps : List [MetadataChangeProposalWrapper ],
668
668
user_mcps : List [MetadataChangeProposalWrapper ],
669
+ dashboard_edges : List [EdgeClass ],
669
670
) -> List [MetadataChangeProposalWrapper ]:
670
671
"""
671
672
Map PowerBi dashboard to Datahub dashboard
@@ -695,6 +696,7 @@ def chart_custom_properties(dashboard: powerbi_data_classes.Dashboard) -> dict:
695
696
lastModified = ChangeAuditStamps (),
696
697
dashboardUrl = dashboard .webUrl ,
697
698
customProperties = {** chart_custom_properties (dashboard )},
699
+ dashboards = dashboard_edges ,
698
700
)
699
701
700
702
info_mcp = self .new_mcp (
@@ -933,7 +935,7 @@ def to_datahub_work_units(
933
935
dashboard : powerbi_data_classes .Dashboard ,
934
936
workspace : powerbi_data_classes .Workspace ,
935
937
) -> List [EquableMetadataWorkUnit ]:
936
- mcps = []
938
+ mcps : List [ MetadataChangeProposalWrapper ] = []
937
939
938
940
logger .info (
939
941
f"Converting dashboard={ dashboard .displayName } to datahub dashboard"
@@ -945,9 +947,35 @@ def to_datahub_work_units(
945
947
)
946
948
# Convert tiles to charts
947
949
ds_mcps , chart_mcps = self .to_datahub_chart (dashboard .tiles , workspace )
950
+
951
+ # collect all downstream reports
952
+ downstream_dashboards_edges = []
953
+ for t in dashboard .tiles :
954
+ if t .report_id :
955
+ report = workspace .reports .get (t .report_id )
956
+ if report is None :
957
+ # a title referencing a missed report was already reported during "fill_dashboards"
958
+ continue
959
+
960
+ dashboard_urn = builder .make_dashboard_urn (
961
+ platform = self .__config .platform_name ,
962
+ platform_instance = self .__config .platform_instance ,
963
+ name = report .get_urn_part (),
964
+ )
965
+ edge = EdgeClass (
966
+ destinationUrn = dashboard_urn ,
967
+ sourceUrn = None ,
968
+ created = None ,
969
+ lastModified = None ,
970
+ properties = None ,
971
+ )
972
+ downstream_dashboards_edges .append (edge )
973
+
948
974
# Lets convert dashboard to datahub dashboard
949
975
dashboard_mcps : List [MetadataChangeProposalWrapper ] = (
950
- self .to_datahub_dashboard_mcp (dashboard , workspace , chart_mcps , user_mcps )
976
+ self .to_datahub_dashboard_mcp (
977
+ dashboard , workspace , chart_mcps , user_mcps , downstream_dashboards_edges
978
+ )
951
979
)
952
980
953
981
# Now add MCPs in sequence
@@ -1054,7 +1082,6 @@ def report_to_dashboard(
1054
1082
report : powerbi_data_classes .Report ,
1055
1083
chart_mcps : List [MetadataChangeProposalWrapper ],
1056
1084
user_mcps : List [MetadataChangeProposalWrapper ],
1057
- dashboard_edges : List [EdgeClass ],
1058
1085
) -> List [MetadataChangeProposalWrapper ]:
1059
1086
"""
1060
1087
Map PowerBi report to Datahub dashboard
@@ -1076,7 +1103,6 @@ def report_to_dashboard(
1076
1103
charts = chart_urn_list ,
1077
1104
lastModified = ChangeAuditStamps (),
1078
1105
dashboardUrl = report .webUrl ,
1079
- dashboards = dashboard_edges ,
1080
1106
)
1081
1107
1082
1108
info_mcp = self .new_mcp (
@@ -1170,27 +1196,12 @@ def report_to_datahub_work_units(
1170
1196
ds_mcps = self .to_datahub_dataset (report .dataset , workspace )
1171
1197
chart_mcps = self .pages_to_chart (report .pages , workspace , ds_mcps )
1172
1198
1173
- # find all dashboards with a Tile referencing this report
1174
- downstream_dashboards_edges = []
1175
- for d in workspace .dashboards .values ():
1176
- if any (t .report_id == report .id for t in d .tiles ):
1177
- dashboard_urn = builder .make_dashboard_urn (
1178
- platform = self .__config .platform_name ,
1179
- platform_instance = self .__config .platform_instance ,
1180
- name = d .get_urn_part (),
1181
- )
1182
- edge = EdgeClass (
1183
- destinationUrn = dashboard_urn ,
1184
- sourceUrn = None ,
1185
- created = None ,
1186
- lastModified = None ,
1187
- properties = None ,
1188
- )
1189
- downstream_dashboards_edges .append (edge )
1190
-
1191
1199
# Let's convert report to datahub dashboard
1192
1200
report_mcps = self .report_to_dashboard (
1193
- workspace , report , chart_mcps , user_mcps , downstream_dashboards_edges
1201
+ workspace ,
1202
+ report ,
1203
+ chart_mcps ,
1204
+ user_mcps ,
1194
1205
)
1195
1206
1196
1207
# Now add MCPs in sequence
0 commit comments