semantic-link-labs 0.4.1__py3-none-any.whl → 0.5.0__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 → semantic_link_labs-0.5.0.dist-info}/METADATA +1 -1
- semantic_link_labs-0.5.0.dist-info/RECORD +53 -0
- {semantic_link_labs-0.4.1.dist-info → semantic_link_labs-0.5.0.dist-info}/WHEEL +1 -1
- sempy_labs/__init__.py +51 -27
- sempy_labs/_ai.py +32 -51
- sempy_labs/_clear_cache.py +2 -3
- sempy_labs/_connections.py +39 -38
- sempy_labs/_dax.py +5 -9
- sempy_labs/_generate_semantic_model.py +15 -21
- sempy_labs/_helper_functions.py +20 -25
- sempy_labs/_icons.py +6 -0
- sempy_labs/_list_functions.py +1172 -392
- sempy_labs/_model_auto_build.py +3 -5
- sempy_labs/_model_bpa.py +20 -24
- sempy_labs/_model_dependencies.py +7 -14
- sempy_labs/_one_lake_integration.py +14 -24
- sempy_labs/_query_scale_out.py +13 -31
- sempy_labs/_refresh_semantic_model.py +8 -18
- sempy_labs/_translations.py +5 -5
- sempy_labs/_vertipaq.py +11 -18
- sempy_labs/directlake/_directlake_schema_compare.py +11 -15
- sempy_labs/directlake/_directlake_schema_sync.py +35 -40
- sempy_labs/directlake/_fallback.py +3 -7
- sempy_labs/directlake/_get_directlake_lakehouse.py +3 -4
- sempy_labs/directlake/_get_shared_expression.py +5 -11
- sempy_labs/directlake/_guardrails.py +5 -7
- sempy_labs/directlake/_list_directlake_model_calc_tables.py +28 -26
- sempy_labs/directlake/_show_unsupported_directlake_objects.py +3 -4
- sempy_labs/directlake/_update_directlake_model_lakehouse_connection.py +11 -16
- sempy_labs/directlake/_update_directlake_partition_entity.py +25 -15
- sempy_labs/directlake/_warm_cache.py +10 -15
- sempy_labs/lakehouse/__init__.py +0 -2
- sempy_labs/lakehouse/_get_lakehouse_columns.py +4 -3
- sempy_labs/lakehouse/_get_lakehouse_tables.py +12 -11
- sempy_labs/lakehouse/_lakehouse.py +6 -7
- sempy_labs/lakehouse/_shortcuts.py +10 -111
- sempy_labs/migration/__init__.py +4 -2
- sempy_labs/migration/_create_pqt_file.py +5 -14
- sempy_labs/migration/_migrate_calctables_to_lakehouse.py +7 -7
- sempy_labs/migration/_migrate_calctables_to_semantic_model.py +4 -4
- sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +3 -8
- sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +6 -6
- sempy_labs/migration/_migration_validation.py +5 -164
- sempy_labs/migration/_refresh_calc_tables.py +5 -5
- sempy_labs/report/__init__.py +2 -2
- sempy_labs/report/_generate_report.py +14 -19
- sempy_labs/report/_report_functions.py +41 -83
- sempy_labs/report/_report_rebind.py +43 -44
- sempy_labs/tom/__init__.py +6 -0
- sempy_labs/{_tom.py → tom/_model.py} +274 -337
- semantic_link_labs-0.4.1.dist-info/RECORD +0 -52
- {semantic_link_labs-0.4.1.dist-info → semantic_link_labs-0.5.0.dist-info}/LICENSE +0 -0
- {semantic_link_labs-0.4.1.dist-info → semantic_link_labs-0.5.0.dist-info}/top_level.txt +0 -0
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import sempy
|
|
2
2
|
import sempy.fabric as fabric
|
|
3
3
|
from sempy_labs._helper_functions import resolve_dataset_id, resolve_report_id
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Optional, List
|
|
5
5
|
from sempy._utils._log import log
|
|
6
6
|
import sempy_labs._icons as icons
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
@log
|
|
10
9
|
def report_rebind(
|
|
11
|
-
report: str,
|
|
10
|
+
report: str | List[str],
|
|
12
11
|
dataset: str,
|
|
13
12
|
report_workspace: Optional[str] = None,
|
|
14
13
|
dataset_workspace: Optional[str] = None,
|
|
@@ -18,8 +17,8 @@ def report_rebind(
|
|
|
18
17
|
|
|
19
18
|
Parameters
|
|
20
19
|
----------
|
|
21
|
-
report : str
|
|
22
|
-
Name of the Power BI report.
|
|
20
|
+
report : str | List[str]
|
|
21
|
+
Name(s) of the Power BI report(s).
|
|
23
22
|
dataset : str
|
|
24
23
|
Name of the semantic model.
|
|
25
24
|
report_workspace : str, default=None
|
|
@@ -36,36 +35,37 @@ def report_rebind(
|
|
|
36
35
|
|
|
37
36
|
"""
|
|
38
37
|
|
|
39
|
-
if report_workspace
|
|
38
|
+
if report_workspace is None:
|
|
40
39
|
report_workspace_id = fabric.get_workspace_id()
|
|
41
40
|
report_workspace = fabric.resolve_workspace_name(report_workspace_id)
|
|
42
41
|
else:
|
|
43
42
|
report_workspace_id = fabric.resolve_workspace_id(report_workspace)
|
|
44
|
-
if dataset_workspace
|
|
43
|
+
if dataset_workspace is None:
|
|
45
44
|
dataset_workspace = report_workspace
|
|
46
45
|
|
|
47
46
|
client = fabric.PowerBIRestClient()
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
if isinstance(report, str):
|
|
49
|
+
report = [report]
|
|
50
|
+
|
|
51
|
+
for rpt in report:
|
|
52
|
+
reportId = resolve_report_id(report=rpt, workspace=report_workspace)
|
|
53
|
+
datasetId = resolve_dataset_id(dataset=dataset, workspace=dataset_workspace)
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
json=request_body,
|
|
58
|
-
)
|
|
55
|
+
# Prepare API
|
|
56
|
+
request_body = {"datasetId": datasetId}
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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."
|
|
58
|
+
response = client.post(
|
|
59
|
+
f"/v1.0/myorg/groups/{report_workspace_id}/reports/{reportId}/Rebind",
|
|
60
|
+
json=request_body,
|
|
67
61
|
)
|
|
68
62
|
|
|
63
|
+
if response.status_code == 200:
|
|
64
|
+
print(
|
|
65
|
+
f"{icons.green_dot} The '{rpt}' report has been successfully rebinded to the '{dataset}' semantic model."
|
|
66
|
+
)
|
|
67
|
+
else:
|
|
68
|
+
raise ValueError(f"{icons.red_dot} The '{rpt}' report within the '{report_workspace}' workspace failed to rebind to the '{dataset}' semantic model within the '{dataset_workspace}' workspace.")
|
|
69
69
|
|
|
70
70
|
@log
|
|
71
71
|
def report_rebind_all(
|
|
@@ -73,7 +73,7 @@ def report_rebind_all(
|
|
|
73
73
|
new_dataset: str,
|
|
74
74
|
dataset_workspace: Optional[str] = None,
|
|
75
75
|
new_dataset_workpace: Optional[str] = None,
|
|
76
|
-
report_workspace: Optional[str] = None,
|
|
76
|
+
report_workspace: Optional[str | List[str]] = None,
|
|
77
77
|
):
|
|
78
78
|
"""
|
|
79
79
|
Rebinds all reports in a workspace which are bound to a specific semantic model to a new semantic model.
|
|
@@ -94,8 +94,8 @@ def report_rebind_all(
|
|
|
94
94
|
The name of the Fabric workspace in which the new semantic model resides.
|
|
95
95
|
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
96
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
|
|
97
|
+
report_workspace : str | List[str], default=None
|
|
98
|
+
The name(s) of the Fabric workspace(s) in which the report(s) reside(s).
|
|
99
99
|
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
100
100
|
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
101
101
|
|
|
@@ -104,28 +104,27 @@ def report_rebind_all(
|
|
|
104
104
|
|
|
105
105
|
"""
|
|
106
106
|
|
|
107
|
-
|
|
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)
|
|
107
|
+
dataset_workspace = fabric.resolve_workspace_name()
|
|
112
108
|
|
|
113
|
-
if new_dataset_workpace
|
|
109
|
+
if new_dataset_workpace is None:
|
|
114
110
|
new_dataset_workpace = dataset_workspace
|
|
115
111
|
|
|
116
|
-
if report_workspace
|
|
112
|
+
if report_workspace is None:
|
|
117
113
|
report_workspace = dataset_workspace
|
|
118
114
|
|
|
119
|
-
|
|
115
|
+
if isinstance(report_workspace, str):
|
|
116
|
+
report_workspace = [report_workspace]
|
|
120
117
|
|
|
121
|
-
|
|
122
|
-
dfRep_filt = dfRep[dfRep["Dataset Id"] == datasetId]
|
|
118
|
+
datasetId = resolve_dataset_id(dataset, dataset_workspace)
|
|
123
119
|
|
|
124
|
-
for
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
120
|
+
for rw in report_workspace:
|
|
121
|
+
dfRep = fabric.list_reports(workspace=rw)
|
|
122
|
+
dfRep_filt = dfRep[dfRep["Dataset Id"] == datasetId]
|
|
123
|
+
for i, r in dfRep_filt.iterrows():
|
|
124
|
+
rptName = r["Name"]
|
|
125
|
+
report_rebind(
|
|
126
|
+
report=rptName,
|
|
127
|
+
dataset=new_dataset,
|
|
128
|
+
report_workspace=rw,
|
|
129
|
+
dataset_workspace=new_dataset_workpace,
|
|
130
|
+
)
|