semantic-link-labs 0.4.1__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 semantic-link-labs might be problematic. Click here for more details.
- semantic_link_labs-0.4.1.dist-info/LICENSE +21 -0
- semantic_link_labs-0.4.1.dist-info/METADATA +22 -0
- semantic_link_labs-0.4.1.dist-info/RECORD +52 -0
- semantic_link_labs-0.4.1.dist-info/WHEEL +5 -0
- semantic_link_labs-0.4.1.dist-info/top_level.txt +1 -0
- sempy_labs/__init__.py +154 -0
- sempy_labs/_ai.py +496 -0
- sempy_labs/_clear_cache.py +39 -0
- sempy_labs/_connections.py +234 -0
- sempy_labs/_dax.py +70 -0
- sempy_labs/_generate_semantic_model.py +280 -0
- sempy_labs/_helper_functions.py +506 -0
- sempy_labs/_icons.py +4 -0
- sempy_labs/_list_functions.py +1372 -0
- sempy_labs/_model_auto_build.py +143 -0
- sempy_labs/_model_bpa.py +1354 -0
- sempy_labs/_model_dependencies.py +341 -0
- sempy_labs/_one_lake_integration.py +155 -0
- sempy_labs/_query_scale_out.py +447 -0
- sempy_labs/_refresh_semantic_model.py +184 -0
- sempy_labs/_tom.py +3766 -0
- sempy_labs/_translations.py +378 -0
- sempy_labs/_vertipaq.py +893 -0
- sempy_labs/directlake/__init__.py +45 -0
- sempy_labs/directlake/_directlake_schema_compare.py +110 -0
- sempy_labs/directlake/_directlake_schema_sync.py +128 -0
- sempy_labs/directlake/_fallback.py +62 -0
- sempy_labs/directlake/_get_directlake_lakehouse.py +69 -0
- sempy_labs/directlake/_get_shared_expression.py +59 -0
- sempy_labs/directlake/_guardrails.py +84 -0
- sempy_labs/directlake/_list_directlake_model_calc_tables.py +54 -0
- sempy_labs/directlake/_show_unsupported_directlake_objects.py +89 -0
- sempy_labs/directlake/_update_directlake_model_lakehouse_connection.py +81 -0
- sempy_labs/directlake/_update_directlake_partition_entity.py +64 -0
- sempy_labs/directlake/_warm_cache.py +210 -0
- sempy_labs/lakehouse/__init__.py +24 -0
- sempy_labs/lakehouse/_get_lakehouse_columns.py +81 -0
- sempy_labs/lakehouse/_get_lakehouse_tables.py +250 -0
- sempy_labs/lakehouse/_lakehouse.py +85 -0
- sempy_labs/lakehouse/_shortcuts.py +296 -0
- sempy_labs/migration/__init__.py +29 -0
- sempy_labs/migration/_create_pqt_file.py +239 -0
- sempy_labs/migration/_migrate_calctables_to_lakehouse.py +429 -0
- sempy_labs/migration/_migrate_calctables_to_semantic_model.py +150 -0
- sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +524 -0
- sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +165 -0
- sempy_labs/migration/_migration_validation.py +227 -0
- sempy_labs/migration/_refresh_calc_tables.py +129 -0
- sempy_labs/report/__init__.py +35 -0
- sempy_labs/report/_generate_report.py +253 -0
- sempy_labs/report/_report_functions.py +855 -0
- sempy_labs/report/_report_rebind.py +131 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import sempy
|
|
2
|
+
import sempy.fabric as fabric
|
|
3
|
+
from sempy_labs._helper_functions import resolve_dataset_id, resolve_report_id
|
|
4
|
+
from typing import List, Optional, Union
|
|
5
|
+
from sempy._utils._log import log
|
|
6
|
+
import sempy_labs._icons as icons
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@log
|
|
10
|
+
def report_rebind(
|
|
11
|
+
report: str,
|
|
12
|
+
dataset: str,
|
|
13
|
+
report_workspace: Optional[str] = None,
|
|
14
|
+
dataset_workspace: Optional[str] = None,
|
|
15
|
+
):
|
|
16
|
+
"""
|
|
17
|
+
Rebinds a report to a semantic model.
|
|
18
|
+
|
|
19
|
+
Parameters
|
|
20
|
+
----------
|
|
21
|
+
report : str
|
|
22
|
+
Name of the Power BI report.
|
|
23
|
+
dataset : str
|
|
24
|
+
Name of the semantic model.
|
|
25
|
+
report_workspace : str, default=None
|
|
26
|
+
The name of the Fabric workspace in which the report resides.
|
|
27
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
28
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
29
|
+
dataset_workspace : str, default=None
|
|
30
|
+
The name of the Fabric workspace in which the semantic model resides.
|
|
31
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
32
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
33
|
+
|
|
34
|
+
Returns
|
|
35
|
+
-------
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
if report_workspace == None:
|
|
40
|
+
report_workspace_id = fabric.get_workspace_id()
|
|
41
|
+
report_workspace = fabric.resolve_workspace_name(report_workspace_id)
|
|
42
|
+
else:
|
|
43
|
+
report_workspace_id = fabric.resolve_workspace_id(report_workspace)
|
|
44
|
+
if dataset_workspace == None:
|
|
45
|
+
dataset_workspace = report_workspace
|
|
46
|
+
|
|
47
|
+
client = fabric.PowerBIRestClient()
|
|
48
|
+
|
|
49
|
+
reportId = resolve_report_id(report=report, workspace=report_workspace)
|
|
50
|
+
datasetId = resolve_dataset_id(dataset=dataset, workspace=dataset_workspace)
|
|
51
|
+
|
|
52
|
+
# Prepare API
|
|
53
|
+
request_body = {"datasetId": datasetId}
|
|
54
|
+
|
|
55
|
+
response = client.post(
|
|
56
|
+
f"/v1.0/myorg/groups/{report_workspace_id}/reports/{reportId}/Rebind",
|
|
57
|
+
json=request_body,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if response.status_code == 200:
|
|
61
|
+
print(
|
|
62
|
+
f"{icons.green_dot} The '{report}' report has been successfully rebinded to the '{dataset}' semantic model."
|
|
63
|
+
)
|
|
64
|
+
else:
|
|
65
|
+
print(
|
|
66
|
+
f"{icons.red_dot} The '{report}' report within the '{report_workspace}' workspace failed to rebind to the '{dataset}' semantic model within the '{dataset_workspace}' workspace."
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@log
|
|
71
|
+
def report_rebind_all(
|
|
72
|
+
dataset: str,
|
|
73
|
+
new_dataset: str,
|
|
74
|
+
dataset_workspace: Optional[str] = None,
|
|
75
|
+
new_dataset_workpace: Optional[str] = None,
|
|
76
|
+
report_workspace: Optional[str] = None,
|
|
77
|
+
):
|
|
78
|
+
"""
|
|
79
|
+
Rebinds all reports in a workspace which are bound to a specific semantic model to a new semantic model.
|
|
80
|
+
|
|
81
|
+
Parameters
|
|
82
|
+
----------
|
|
83
|
+
report : str
|
|
84
|
+
Name of the Power BI report.
|
|
85
|
+
dataset : str
|
|
86
|
+
Name of the semantic model currently binded to the reports.
|
|
87
|
+
new_dataset : str
|
|
88
|
+
Name of the semantic model to rebind to the reports.
|
|
89
|
+
dataset_workspace : str, default=None
|
|
90
|
+
The name of the Fabric workspace in which the original semantic model resides.
|
|
91
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
92
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
93
|
+
new_dataset_workspace : str, default=None
|
|
94
|
+
The name of the Fabric workspace in which the new semantic model resides.
|
|
95
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
96
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
97
|
+
report_workspace : str, default=None
|
|
98
|
+
The name of the Fabric workspace in which the report resides.
|
|
99
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
100
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
101
|
+
|
|
102
|
+
Returns
|
|
103
|
+
-------
|
|
104
|
+
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
if dataset_workspace == None:
|
|
108
|
+
dataset_workspace_id = fabric.get_workspace_id()
|
|
109
|
+
dataset_workspace = fabric.resolve_workspace_name(dataset_workspace_id)
|
|
110
|
+
else:
|
|
111
|
+
dataset_workspace_id = fabric.resolve_workspace_id(dataset_workspace)
|
|
112
|
+
|
|
113
|
+
if new_dataset_workpace == None:
|
|
114
|
+
new_dataset_workpace = dataset_workspace
|
|
115
|
+
|
|
116
|
+
if report_workspace == None:
|
|
117
|
+
report_workspace = dataset_workspace
|
|
118
|
+
|
|
119
|
+
datasetId = resolve_dataset_id(dataset, dataset_workspace)
|
|
120
|
+
|
|
121
|
+
dfRep = fabric.list_reports(workspace=report_workspace)
|
|
122
|
+
dfRep_filt = dfRep[dfRep["Dataset Id"] == datasetId]
|
|
123
|
+
|
|
124
|
+
for i, r in dfRep_filt.iterrows():
|
|
125
|
+
rptName = r["Name"]
|
|
126
|
+
report_rebind(
|
|
127
|
+
report=rptName,
|
|
128
|
+
dataset=new_dataset,
|
|
129
|
+
report_workspace=report_workspace,
|
|
130
|
+
dataset_workspace=new_dataset_workpace,
|
|
131
|
+
)
|