semantic-link-labs 0.11.3__py3-none-any.whl → 0.12.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.11.3.dist-info → semantic_link_labs-0.12.0.dist-info}/METADATA +5 -4
- {semantic_link_labs-0.11.3.dist-info → semantic_link_labs-0.12.0.dist-info}/RECORD +77 -73
- sempy_labs/__init__.py +6 -0
- sempy_labs/_a_lib_info.py +1 -1
- sempy_labs/_authentication.py +81 -32
- sempy_labs/_capacities.py +2 -2
- sempy_labs/_capacity_migration.py +4 -4
- sempy_labs/_clear_cache.py +1 -1
- sempy_labs/_connections.py +107 -70
- sempy_labs/_dashboards.py +6 -2
- sempy_labs/_data_pipelines.py +1 -1
- sempy_labs/_dataflows.py +1 -1
- sempy_labs/_dax.py +3 -3
- sempy_labs/_delta_analyzer.py +4 -4
- sempy_labs/_delta_analyzer_history.py +1 -1
- sempy_labs/_deployment_pipelines.py +1 -1
- sempy_labs/_environments.py +1 -1
- sempy_labs/_eventhouses.py +9 -3
- sempy_labs/_eventstreams.py +1 -1
- sempy_labs/_external_data_shares.py +1 -1
- sempy_labs/_gateways.py +14 -7
- sempy_labs/_generate_semantic_model.py +7 -12
- sempy_labs/_git.py +1 -1
- sempy_labs/_graphQL.py +1 -1
- sempy_labs/_helper_functions.py +161 -54
- sempy_labs/_job_scheduler.py +12 -1
- sempy_labs/_kql_databases.py +1 -1
- sempy_labs/_kql_querysets.py +10 -2
- sempy_labs/_kusto.py +2 -2
- sempy_labs/_list_functions.py +1 -1
- sempy_labs/_managed_private_endpoints.py +1 -1
- sempy_labs/_mirrored_databases.py +40 -16
- sempy_labs/_mirrored_warehouses.py +1 -1
- sempy_labs/_ml_experiments.py +1 -1
- sempy_labs/_model_bpa.py +6 -6
- sempy_labs/_model_bpa_bulk.py +3 -3
- sempy_labs/_model_dependencies.py +1 -1
- sempy_labs/_mounted_data_factories.py +3 -3
- sempy_labs/_notebooks.py +2 -1
- sempy_labs/_query_scale_out.py +2 -2
- sempy_labs/_refresh_semantic_model.py +1 -1
- sempy_labs/_semantic_models.py +15 -3
- sempy_labs/_spark.py +1 -1
- sempy_labs/_sql.py +3 -3
- sempy_labs/_sql_endpoints.py +5 -3
- sempy_labs/_sqldatabase.py +5 -1
- sempy_labs/_tags.py +3 -1
- sempy_labs/_translations.py +7 -360
- sempy_labs/_user_delegation_key.py +2 -2
- sempy_labs/_utils.py +27 -0
- sempy_labs/_vertipaq.py +3 -3
- sempy_labs/_vpax.py +1 -1
- sempy_labs/_warehouses.py +5 -0
- sempy_labs/_workloads.py +1 -1
- sempy_labs/_workspace_identity.py +1 -1
- sempy_labs/_workspaces.py +145 -11
- sempy_labs/admin/__init__.py +6 -0
- sempy_labs/admin/_capacities.py +34 -11
- sempy_labs/admin/_items.py +2 -2
- sempy_labs/admin/_tenant_keys.py +89 -0
- sempy_labs/directlake/_dl_helper.py +1 -1
- sempy_labs/lakehouse/__init__.py +4 -0
- sempy_labs/lakehouse/_materialized_lake_views.py +76 -0
- sempy_labs/lakehouse/_shortcuts.py +8 -2
- sempy_labs/report/_bpareporttemplate/.pbi/localSettings.json +9 -0
- sempy_labs/report/_bpareporttemplate/.platform +11 -0
- sempy_labs/report/_download_report.py +4 -1
- sempy_labs/report/_export_report.py +12 -5
- sempy_labs/report/_generate_report.py +11 -3
- sempy_labs/report/_paginated.py +21 -15
- sempy_labs/report/_report_functions.py +19 -11
- sempy_labs/report/_report_rebind.py +21 -10
- sempy_labs/theme/_org_themes.py +5 -6
- sempy_labs/tom/_model.py +5 -16
- {semantic_link_labs-0.11.3.dist-info → semantic_link_labs-0.12.0.dist-info}/WHEEL +0 -0
- {semantic_link_labs-0.11.3.dist-info → semantic_link_labs-0.12.0.dist-info}/licenses/LICENSE +0 -0
- {semantic_link_labs-0.11.3.dist-info → semantic_link_labs-0.12.0.dist-info}/top_level.txt +0 -0
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
5
5
|
from typing import Optional
|
|
6
|
-
from
|
|
6
|
+
from sempy_labs._helper_functions import (
|
|
7
7
|
resolve_workspace_name_and_id,
|
|
8
8
|
_conv_b64,
|
|
9
9
|
resolve_dataset_name_and_id,
|
|
@@ -11,7 +11,7 @@ from .._helper_functions import (
|
|
|
11
11
|
_update_dataframe_datatypes,
|
|
12
12
|
_base_api,
|
|
13
13
|
resolve_item_id,
|
|
14
|
-
|
|
14
|
+
_get_item_definition,
|
|
15
15
|
)
|
|
16
16
|
import sempy_labs._icons as icons
|
|
17
17
|
from sempy._utils._log import log
|
|
@@ -31,6 +31,8 @@ def create_report_from_reportjson(
|
|
|
31
31
|
|
|
32
32
|
This is a wrapper function for the following API: `Items - Create Report <https://learn.microsoft.com/rest/api/fabric/report/items/create-report>`_.
|
|
33
33
|
|
|
34
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
35
|
+
|
|
34
36
|
Parameters
|
|
35
37
|
----------
|
|
36
38
|
report : str
|
|
@@ -113,6 +115,7 @@ def create_report_from_reportjson(
|
|
|
113
115
|
payload=request_body,
|
|
114
116
|
lro_return_status_code=True,
|
|
115
117
|
status_codes=[201, 202],
|
|
118
|
+
client="fabric_sp",
|
|
116
119
|
)
|
|
117
120
|
|
|
118
121
|
print(
|
|
@@ -129,6 +132,8 @@ def update_report_from_reportjson(
|
|
|
129
132
|
|
|
130
133
|
This is a wrapper function for the following API: `Items - Update Report Definition <https://learn.microsoft.com/rest/api/fabric/report/items/update-report-definition>`_.
|
|
131
134
|
|
|
135
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
136
|
+
|
|
132
137
|
Parameters
|
|
133
138
|
----------
|
|
134
139
|
report : str | uuid.UUID
|
|
@@ -173,6 +178,7 @@ def update_report_from_reportjson(
|
|
|
173
178
|
payload=payload,
|
|
174
179
|
lro_return_status_code=True,
|
|
175
180
|
status_codes=None,
|
|
181
|
+
client="fabric_sp",
|
|
176
182
|
)
|
|
177
183
|
|
|
178
184
|
print(
|
|
@@ -191,6 +197,8 @@ def get_report_definition(
|
|
|
191
197
|
|
|
192
198
|
This is a wrapper function for the following API: `Items - Get Report Definition <https://learn.microsoft.com/rest/api/fabric/report/items/get-report-definition>`_.
|
|
193
199
|
|
|
200
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
201
|
+
|
|
194
202
|
Parameters
|
|
195
203
|
----------
|
|
196
204
|
report : str | uuid.UUID
|
|
@@ -208,7 +216,7 @@ def get_report_definition(
|
|
|
208
216
|
The collection of report definition files within a pandas dataframe.
|
|
209
217
|
"""
|
|
210
218
|
|
|
211
|
-
return
|
|
219
|
+
return _get_item_definition(
|
|
212
220
|
item=report,
|
|
213
221
|
type="Report",
|
|
214
222
|
workspace=workspace,
|
sempy_labs/report/_paginated.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
import pandas as pd
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
|
|
4
|
+
from sempy_labs._helper_functions import (
|
|
5
|
+
resolve_workspace_id,
|
|
6
6
|
_base_api,
|
|
7
7
|
resolve_item_id,
|
|
8
8
|
_create_dataframe,
|
|
@@ -18,6 +18,8 @@ def get_report_datasources(
|
|
|
18
18
|
"""
|
|
19
19
|
Returns a list of data sources for the specified paginated report (RDL) from the specified workspace.
|
|
20
20
|
|
|
21
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
22
|
+
|
|
21
23
|
Parameters
|
|
22
24
|
----------
|
|
23
25
|
report : str | uuid.UUID
|
|
@@ -44,27 +46,31 @@ def get_report_datasources(
|
|
|
44
46
|
}
|
|
45
47
|
df = _create_dataframe(columns=columns)
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
workspace_id = resolve_workspace_id(workspace)
|
|
48
50
|
report_id = resolve_item_id(
|
|
49
51
|
item=report, type="PaginatedReport", workspace=workspace
|
|
50
52
|
)
|
|
51
53
|
|
|
52
54
|
response = _base_api(
|
|
53
|
-
request=f"v1.0/myorg/groups/{workspace_id}/reports/{report_id}/datasources"
|
|
55
|
+
request=f"v1.0/myorg/groups/{workspace_id}/reports/{report_id}/datasources",
|
|
56
|
+
client="fabric_sp",
|
|
54
57
|
)
|
|
55
58
|
|
|
59
|
+
rows = []
|
|
56
60
|
for i in response.json().get("value", []):
|
|
57
61
|
conn = i.get("connectionDetails", {})
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
rows.append(
|
|
63
|
+
{
|
|
64
|
+
"Report Name": report,
|
|
65
|
+
"Report Id": report_id,
|
|
66
|
+
"Datasource Id": i.get("datasourceId"),
|
|
67
|
+
"Datasource Type": i.get("datasourceType"),
|
|
68
|
+
"Gateway Id": i.get("gatewayId"),
|
|
69
|
+
"Server": conn.get("server") if conn else None,
|
|
70
|
+
"Database": conn.get("database") if conn else None,
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
if rows:
|
|
74
|
+
df = pd.DataFrame(rows, columns=list(columns.keys()))
|
|
69
75
|
|
|
70
76
|
return df
|
|
@@ -19,6 +19,7 @@ from .._helper_functions import (
|
|
|
19
19
|
_create_spark_session,
|
|
20
20
|
_mount,
|
|
21
21
|
resolve_workspace_id,
|
|
22
|
+
resolve_item_name_and_id,
|
|
22
23
|
)
|
|
23
24
|
from typing import List, Optional, Union
|
|
24
25
|
from sempy._utils._log import log
|
|
@@ -33,14 +34,14 @@ def get_report_json(
|
|
|
33
34
|
save_to_file_name: Optional[str] = None,
|
|
34
35
|
) -> dict:
|
|
35
36
|
"""
|
|
36
|
-
Gets the report.json file content of a Power BI report.
|
|
37
|
+
Gets the report.json file content of a Power BI report. This function only supports reports in the PBIR-Legacy format.
|
|
37
38
|
|
|
38
39
|
This is a wrapper function for the following API: `Items - Get Report Definition <https://learn.microsoft.com/rest/api/fabric/report/items/get-report-definition>`_.
|
|
39
40
|
|
|
40
41
|
Parameters
|
|
41
42
|
----------
|
|
42
|
-
report : str
|
|
43
|
-
Name of the Power BI report.
|
|
43
|
+
report : str | uuid.UUID
|
|
44
|
+
Name or ID of the Power BI report.
|
|
44
45
|
workspace : str | uuid.UUID, default=None
|
|
45
46
|
The Fabric workspace name or ID in which the report exists.
|
|
46
47
|
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
@@ -55,20 +56,27 @@ def get_report_json(
|
|
|
55
56
|
"""
|
|
56
57
|
|
|
57
58
|
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
58
|
-
report_id =
|
|
59
|
-
|
|
59
|
+
(report_name, report_id) = resolve_item_name_and_id(
|
|
60
|
+
item=report, type="Report", workspace=workspace_id
|
|
61
|
+
)
|
|
60
62
|
|
|
61
63
|
result = _base_api(
|
|
62
|
-
request=f"/v1/workspaces/{workspace_id}/reports/{report_id}/getDefinition
|
|
64
|
+
request=f"/v1/workspaces/{workspace_id}/reports/{report_id}/getDefinition",
|
|
63
65
|
method="post",
|
|
64
66
|
lro_return_json=True,
|
|
65
67
|
status_codes=None,
|
|
66
68
|
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
report_json = None
|
|
70
|
+
for part in result.get("definition", {}).get("parts", {}):
|
|
71
|
+
if part.get("path") == "report.json":
|
|
72
|
+
payload = part.get("payload")
|
|
73
|
+
report_file = _decode_b64(payload)
|
|
74
|
+
report_json = json.loads(report_file)
|
|
75
|
+
|
|
76
|
+
if not report_json:
|
|
77
|
+
raise ValueError(
|
|
78
|
+
f"{icons.red_dot} Unable to retrieve report.json for the '{report_name}' report within the '{workspace_name}' workspace. This function only supports reports in the PBIR-Legacy format."
|
|
79
|
+
)
|
|
72
80
|
|
|
73
81
|
if save_to_file_name is not None:
|
|
74
82
|
if not lakehouse_attached():
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
from
|
|
2
|
-
resolve_dataset_id,
|
|
1
|
+
from sempy_labs._helper_functions import (
|
|
3
2
|
resolve_workspace_name_and_id,
|
|
4
|
-
|
|
3
|
+
resolve_item_name_and_id,
|
|
5
4
|
_base_api,
|
|
6
5
|
resolve_dataset_name_and_id,
|
|
7
6
|
)
|
|
@@ -23,12 +22,14 @@ def report_rebind(
|
|
|
23
22
|
|
|
24
23
|
This is a wrapper function for the following API: `Reports - Rebind Report In Group <https://learn.microsoft.com/rest/api/power-bi/reports/rebind-report-in-group>`_.
|
|
25
24
|
|
|
25
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
26
|
+
|
|
26
27
|
Parameters
|
|
27
28
|
----------
|
|
28
|
-
report : str | List[str]
|
|
29
|
-
Name(s) of the Power BI report(s).
|
|
30
|
-
dataset : str
|
|
31
|
-
Name of the semantic model.
|
|
29
|
+
report : str | uuid.UUID | List[str | uuid.UUID]
|
|
30
|
+
Name(s) or ID(s) of the Power BI report(s).
|
|
31
|
+
dataset : str | uuid.UUID
|
|
32
|
+
Name or ID of the semantic model.
|
|
32
33
|
report_workspace : str | uuid.UUID, default=None
|
|
33
34
|
The name or ID of the Fabric workspace in which the report resides.
|
|
34
35
|
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
@@ -46,12 +47,19 @@ def report_rebind(
|
|
|
46
47
|
if dataset_workspace is None:
|
|
47
48
|
dataset_workspace = report_workspace_name
|
|
48
49
|
|
|
50
|
+
(dataset_workspace_name, dataset_workspace_id) = resolve_workspace_name_and_id(
|
|
51
|
+
dataset_workspace
|
|
52
|
+
)
|
|
49
53
|
if isinstance(report, str):
|
|
50
54
|
report = [report]
|
|
51
55
|
|
|
52
56
|
for rpt in report:
|
|
53
|
-
report_id =
|
|
54
|
-
|
|
57
|
+
(report_name, report_id) = resolve_item_name_and_id(
|
|
58
|
+
item=rpt, type="Report", workspace=report_workspace_id
|
|
59
|
+
)
|
|
60
|
+
(dataset_name, dataset_id) = resolve_item_name_and_id(
|
|
61
|
+
item=dataset, type="SemanticModel", workspace=dataset_workspace
|
|
62
|
+
)
|
|
55
63
|
|
|
56
64
|
payload = {"datasetId": dataset_id}
|
|
57
65
|
|
|
@@ -59,10 +67,11 @@ def report_rebind(
|
|
|
59
67
|
request=f"v1.0/myorg/groups/{report_workspace_id}/reports/{report_id}/Rebind",
|
|
60
68
|
method="post",
|
|
61
69
|
payload=payload,
|
|
70
|
+
client="fabric_sp",
|
|
62
71
|
)
|
|
63
72
|
|
|
64
73
|
print(
|
|
65
|
-
f"{icons.green_dot} The '{
|
|
74
|
+
f"{icons.green_dot} The '{report_name}' report within the '{report_workspace_name}' workspace has been successfully rebinded to the '{dataset_name}' semantic model within the '{dataset_workspace_name}' workspace."
|
|
66
75
|
)
|
|
67
76
|
|
|
68
77
|
|
|
@@ -77,6 +86,8 @@ def report_rebind_all(
|
|
|
77
86
|
"""
|
|
78
87
|
Rebinds all reports across all workspaces which are bound to a specific semantic model to a new semantic model.
|
|
79
88
|
|
|
89
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
90
|
+
|
|
80
91
|
Parameters
|
|
81
92
|
----------
|
|
82
93
|
dataset : str
|
sempy_labs/theme/_org_themes.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import pandas as pd
|
|
2
2
|
from uuid import UUID
|
|
3
|
-
from
|
|
3
|
+
from sempy_labs._helper_functions import (
|
|
4
4
|
_is_valid_uuid,
|
|
5
5
|
_base_api,
|
|
6
6
|
_update_dataframe_datatypes,
|
|
@@ -9,6 +9,7 @@ from .._helper_functions import (
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
_pbi_url_prefix = None
|
|
12
|
+
_theme_url_prefix = "metadata/v202409/organization/themes"
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def init_pbi_url_prefix():
|
|
@@ -44,7 +45,7 @@ def list_org_themes() -> pd.DataFrame:
|
|
|
44
45
|
|
|
45
46
|
df = _create_dataframe(columns=columns)
|
|
46
47
|
|
|
47
|
-
response = _base_api(request=f"{_pbi_url_prefix}/
|
|
48
|
+
response = _base_api(request=f"{_pbi_url_prefix}/{_theme_url_prefix}")
|
|
48
49
|
|
|
49
50
|
result = response.json().get("orgThemes")
|
|
50
51
|
if result:
|
|
@@ -110,9 +111,7 @@ def get_org_theme_json(theme: str | UUID) -> dict:
|
|
|
110
111
|
init_pbi_url_prefix()
|
|
111
112
|
|
|
112
113
|
theme_id = resolve_theme_id(theme)
|
|
113
|
-
response = _base_api(
|
|
114
|
-
request=f"{_pbi_url_prefix}/metadata/organization/themes/{theme_id}"
|
|
115
|
-
)
|
|
114
|
+
response = _base_api(request=f"{_pbi_url_prefix}/{_theme_url_prefix}/{theme_id}")
|
|
116
115
|
return response.json().get("themeJson", {})
|
|
117
116
|
|
|
118
117
|
|
|
@@ -124,7 +123,7 @@ def delete_org_theme(theme: str | UUID) -> None:
|
|
|
124
123
|
|
|
125
124
|
theme_id = resolve_theme_id(theme)
|
|
126
125
|
_base_api(
|
|
127
|
-
request=f"{_pbi_url_prefix}/
|
|
126
|
+
request=f"{_pbi_url_prefix}/{_theme_url_prefix}/{theme_id}",
|
|
128
127
|
method="delete",
|
|
129
128
|
status_codes=204,
|
|
130
129
|
)
|
sempy_labs/tom/_model.py
CHANGED
|
@@ -5127,25 +5127,14 @@ class TOMWrapper:
|
|
|
5127
5127
|
Generates the M expression for the import partition.
|
|
5128
5128
|
"""
|
|
5129
5129
|
|
|
5130
|
-
if artifact_type == "Lakehouse":
|
|
5131
|
-
type_id = "lakehouseId"
|
|
5132
|
-
elif artifact_type == "Warehouse":
|
|
5133
|
-
type_id = "warehouseId"
|
|
5134
|
-
else:
|
|
5135
|
-
raise NotImplementedError
|
|
5136
|
-
|
|
5137
5130
|
full_table_name = (
|
|
5138
|
-
f"{schema_name}
|
|
5131
|
+
f"{schema_name}/{table_name}" if schema_name else table_name
|
|
5139
5132
|
)
|
|
5140
5133
|
|
|
5141
|
-
return f"""let
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
result = #"Artifact"{{[Id="{full_table_name}",ItemKind="Table"]}}[Data]
|
|
5146
|
-
in
|
|
5147
|
-
result
|
|
5148
|
-
"""
|
|
5134
|
+
return f"""let\n\tSource = AzureStorage.DataLake("https://onelake.dfs.fabric.microsoft.com/{workspace_id}/{artifact_id}", [HierarchicalNavigation=true]),
|
|
5135
|
+
Tables = Source{{[Name = "Tables"]}}[Content],
|
|
5136
|
+
ExpressionTable = Tables{{[Name = "{full_table_name}"]}}[Content],
|
|
5137
|
+
ToDelta = DeltaLake.Table(ExpressionTable)\nin\n\tToDelta"""
|
|
5149
5138
|
|
|
5150
5139
|
m_expression = _generate_m_expression(
|
|
5151
5140
|
source_workspace_id,
|
|
File without changes
|
{semantic_link_labs-0.11.3.dist-info → semantic_link_labs-0.12.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|