semantic-link-labs 0.8.3__py3-none-any.whl → 0.8.5__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.8.3.dist-info → semantic_link_labs-0.8.5.dist-info}/METADATA +38 -8
- {semantic_link_labs-0.8.3.dist-info → semantic_link_labs-0.8.5.dist-info}/RECORD +109 -104
- {semantic_link_labs-0.8.3.dist-info → semantic_link_labs-0.8.5.dist-info}/WHEEL +1 -1
- sempy_labs/__init__.py +53 -1
- sempy_labs/_bpa_translation/_model/_translations_am-ET.po +24 -5
- sempy_labs/_bpa_translation/_model/_translations_ar-AE.po +28 -4
- sempy_labs/_bpa_translation/_model/_translations_bg-BG.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_ca-ES.po +33 -4
- sempy_labs/_bpa_translation/_model/_translations_cs-CZ.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_da-DK.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_de-DE.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_el-GR.po +36 -4
- sempy_labs/_bpa_translation/_model/_translations_es-ES.po +90 -58
- sempy_labs/_bpa_translation/_model/_translations_fa-IR.po +31 -5
- sempy_labs/_bpa_translation/_model/_translations_fi-FI.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_fr-FR.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_ga-IE.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_he-IL.po +28 -4
- sempy_labs/_bpa_translation/_model/_translations_hi-IN.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_hu-HU.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_id-ID.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_is-IS.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_it-IT.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_ja-JP.po +24 -4
- sempy_labs/_bpa_translation/_model/_translations_ko-KR.po +72 -56
- sempy_labs/_bpa_translation/_model/_translations_mt-MT.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_nl-NL.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_pl-PL.po +95 -71
- sempy_labs/_bpa_translation/_model/_translations_pt-BR.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_pt-PT.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_ro-RO.po +33 -4
- sempy_labs/_bpa_translation/_model/_translations_ru-RU.po +34 -4
- sempy_labs/_bpa_translation/_model/_translations_sk-SK.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_sl-SL.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_sv-SE.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_ta-IN.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_te-IN.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_th-TH.po +31 -4
- sempy_labs/_bpa_translation/_model/_translations_tr-TR.po +32 -4
- sempy_labs/_bpa_translation/_model/_translations_uk-UA.po +100 -72
- sempy_labs/_bpa_translation/_model/_translations_zh-CN.po +23 -5
- sempy_labs/_bpa_translation/_model/_translations_zu-ZA.po +32 -4
- sempy_labs/_capacities.py +49 -14
- sempy_labs/_capacity_migration.py +1 -7
- sempy_labs/_data_pipelines.py +6 -0
- sempy_labs/_dataflows.py +118 -1
- sempy_labs/_dax.py +189 -3
- sempy_labs/_deployment_pipelines.py +13 -7
- sempy_labs/_environments.py +6 -0
- sempy_labs/_eventhouses.py +6 -0
- sempy_labs/_eventstreams.py +6 -0
- sempy_labs/_external_data_shares.py +6 -4
- sempy_labs/_generate_semantic_model.py +26 -3
- sempy_labs/_git.py +14 -14
- sempy_labs/_helper_functions.py +197 -1
- sempy_labs/_icons.py +55 -22
- sempy_labs/_kql_databases.py +6 -0
- sempy_labs/_kql_querysets.py +6 -0
- sempy_labs/_list_functions.py +1 -1
- sempy_labs/_managed_private_endpoints.py +166 -0
- sempy_labs/_mirrored_databases.py +428 -0
- sempy_labs/_mirrored_warehouses.py +2 -0
- sempy_labs/_ml_experiments.py +6 -0
- sempy_labs/_ml_models.py +7 -1
- sempy_labs/_model_bpa.py +215 -181
- sempy_labs/_model_bpa_bulk.py +46 -42
- sempy_labs/_model_bpa_rules.py +8 -3
- sempy_labs/_model_dependencies.py +41 -87
- sempy_labs/_notebooks.py +107 -12
- sempy_labs/_query_scale_out.py +8 -6
- sempy_labs/_refresh_semantic_model.py +299 -49
- sempy_labs/_spark.py +12 -5
- sempy_labs/_translations.py +2 -0
- sempy_labs/_vertipaq.py +89 -86
- sempy_labs/_warehouses.py +79 -0
- sempy_labs/_workloads.py +128 -0
- sempy_labs/_workspace_identity.py +4 -4
- sempy_labs/_workspaces.py +14 -1
- sempy_labs/admin/__init__.py +2 -0
- sempy_labs/admin/_basic_functions.py +131 -43
- sempy_labs/admin/_domains.py +18 -18
- sempy_labs/directlake/__init__.py +2 -0
- sempy_labs/directlake/_directlake_schema_sync.py +2 -1
- sempy_labs/directlake/_dl_helper.py +4 -1
- sempy_labs/directlake/_get_shared_expression.py +7 -1
- sempy_labs/directlake/_guardrails.py +2 -1
- sempy_labs/directlake/_show_unsupported_directlake_objects.py +1 -7
- sempy_labs/directlake/_update_directlake_model_lakehouse_connection.py +78 -0
- sempy_labs/directlake/_update_directlake_partition_entity.py +13 -32
- sempy_labs/directlake/_warm_cache.py +10 -9
- sempy_labs/lakehouse/_get_lakehouse_tables.py +6 -2
- sempy_labs/lakehouse/_shortcuts.py +4 -0
- sempy_labs/migration/_create_pqt_file.py +5 -2
- sempy_labs/migration/_migrate_calctables_to_lakehouse.py +3 -2
- sempy_labs/migration/_migrate_calctables_to_semantic_model.py +2 -0
- sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +2 -8
- sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +17 -0
- sempy_labs/migration/_migration_validation.py +2 -0
- sempy_labs/migration/_refresh_calc_tables.py +1 -0
- sempy_labs/report/__init__.py +6 -1
- sempy_labs/report/_download_report.py +75 -0
- sempy_labs/report/_generate_report.py +6 -0
- sempy_labs/report/_paginated.py +74 -0
- sempy_labs/report/_report_functions.py +6 -0
- sempy_labs/report/_report_rebind.py +2 -0
- sempy_labs/report/_reportwrapper.py +4 -2
- sempy_labs/tom/_model.py +135 -68
- {semantic_link_labs-0.8.3.dist-info → semantic_link_labs-0.8.5.dist-info}/LICENSE +0 -0
- {semantic_link_labs-0.8.3.dist-info → semantic_link_labs-0.8.5.dist-info}/top_level.txt +0 -0
sempy_labs/_model_bpa_rules.py
CHANGED
|
@@ -158,6 +158,7 @@ def model_bpa_rules(
|
|
|
158
158
|
and r.ToTable.Name == obj.Name
|
|
159
159
|
for r in tom.used_in_relationships(object=obj)
|
|
160
160
|
),
|
|
161
|
+
"When using DirectQuery, dimension tables should be set to Dual mode in order to improve query performance.",
|
|
161
162
|
"https://learn.microsoft.com/power-bi/transform-model/desktop-storage-mode#propagation-of-the-dual-setting",
|
|
162
163
|
),
|
|
163
164
|
(
|
|
@@ -492,6 +493,7 @@ def model_bpa_rules(
|
|
|
492
493
|
obj.Expression,
|
|
493
494
|
flags=re.IGNORECASE,
|
|
494
495
|
),
|
|
496
|
+
"Adding a constant value may lead to performance degradation.",
|
|
495
497
|
),
|
|
496
498
|
(
|
|
497
499
|
"DAX Expressions",
|
|
@@ -643,14 +645,15 @@ def model_bpa_rules(
|
|
|
643
645
|
"Calculation groups with no calculation items",
|
|
644
646
|
lambda obj, tom: obj.CalculationGroup is not None
|
|
645
647
|
and not any(obj.CalculationGroup.CalculationItems),
|
|
648
|
+
"Calculation groups have no function unless they have calculation items.",
|
|
646
649
|
),
|
|
647
650
|
(
|
|
648
651
|
"Maintenance",
|
|
649
|
-
"Column",
|
|
652
|
+
["Column", "Measure", "Table"],
|
|
650
653
|
"Info",
|
|
651
654
|
"Visible objects with no description",
|
|
652
655
|
lambda obj, tom: obj.IsHidden is False and len(obj.Description) == 0,
|
|
653
|
-
"
|
|
656
|
+
"Add descriptions to objects. These descriptions are shown on hover within the Field List in Power BI Desktop. Additionally, you can leverage these descriptions to create an automated data dictionary.",
|
|
654
657
|
),
|
|
655
658
|
(
|
|
656
659
|
"Formatting",
|
|
@@ -710,6 +713,7 @@ def model_bpa_rules(
|
|
|
710
713
|
"Percentages should be formatted with thousands separators and 1 decimal",
|
|
711
714
|
lambda obj, tom: "%" in obj.FormatString
|
|
712
715
|
and obj.FormatString != "#,0.0%;-#,0.0%;#,0.0%",
|
|
716
|
+
"For a better user experience, percengage measures should be formatted with a '%' sign.",
|
|
713
717
|
),
|
|
714
718
|
(
|
|
715
719
|
"Formatting",
|
|
@@ -719,6 +723,7 @@ def model_bpa_rules(
|
|
|
719
723
|
lambda obj, tom: "$" not in obj.FormatString
|
|
720
724
|
and "%" not in obj.FormatString
|
|
721
725
|
and obj.FormatString not in ["#,0", "#,0.0"],
|
|
726
|
+
"For a better user experience, whole numbers should be formatted with commas.",
|
|
722
727
|
),
|
|
723
728
|
(
|
|
724
729
|
"Formatting",
|
|
@@ -731,7 +736,7 @@ def model_bpa_rules(
|
|
|
731
736
|
and r.FromCardinality == TOM.RelationshipEndCardinality.Many
|
|
732
737
|
for r in tom.used_in_relationships(object=obj)
|
|
733
738
|
),
|
|
734
|
-
"Foreign keys should always be hidden.",
|
|
739
|
+
"Foreign keys should always be hidden as they should not be used by end users.",
|
|
735
740
|
),
|
|
736
741
|
(
|
|
737
742
|
"Formatting",
|
|
@@ -160,28 +160,26 @@ def get_model_calc_dependencies(
|
|
|
160
160
|
"""
|
|
161
161
|
|
|
162
162
|
workspace = fabric.resolve_workspace_name(workspace)
|
|
163
|
-
|
|
164
163
|
dep = fabric.evaluate_dax(
|
|
165
164
|
dataset=dataset,
|
|
166
165
|
workspace=workspace,
|
|
167
166
|
dax_string="""
|
|
168
167
|
SELECT
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
[TABLE] AS [Table Name],
|
|
169
|
+
[OBJECT] AS [Object Name],
|
|
170
|
+
[OBJECT_TYPE] AS [Object Type],
|
|
171
|
+
[EXPRESSION] AS [Expression],
|
|
172
|
+
[REFERENCED_TABLE] AS [Referenced Table],
|
|
173
|
+
[REFERENCED_OBJECT] AS [Referenced Object],
|
|
174
|
+
[REFERENCED_OBJECT_TYPE] AS [Referenced Object Type]
|
|
176
175
|
FROM $SYSTEM.DISCOVER_CALC_DEPENDENCY
|
|
177
176
|
""",
|
|
178
177
|
)
|
|
179
|
-
|
|
178
|
+
# Format data columns
|
|
180
179
|
dep["Object Type"] = dep["Object Type"].str.replace("_", " ").str.title()
|
|
181
180
|
dep["Referenced Object Type"] = (
|
|
182
181
|
dep["Referenced Object Type"].str.replace("_", " ").str.title()
|
|
183
182
|
)
|
|
184
|
-
|
|
185
183
|
dep["Full Object Name"] = format_dax_object_name(
|
|
186
184
|
dep["Table Name"], dep["Object Name"]
|
|
187
185
|
)
|
|
@@ -189,83 +187,39 @@ def get_model_calc_dependencies(
|
|
|
189
187
|
dep["Referenced Table"], dep["Referenced Object"]
|
|
190
188
|
)
|
|
191
189
|
dep["Parent Node"] = dep["Object Name"]
|
|
192
|
-
|
|
193
|
-
df = dep
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
df["Done"]
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
],
|
|
226
|
-
"Done": d,
|
|
227
|
-
"Full Object Name": r["Full Object Name"],
|
|
228
|
-
"Referenced Full Object Name": dependency.iloc[
|
|
229
|
-
7
|
|
230
|
-
],
|
|
231
|
-
"Parent Node": rObj,
|
|
232
|
-
}
|
|
233
|
-
]
|
|
234
|
-
),
|
|
235
|
-
],
|
|
236
|
-
ignore_index=True,
|
|
237
|
-
)
|
|
238
|
-
else:
|
|
239
|
-
df = pd.concat(
|
|
240
|
-
[
|
|
241
|
-
df,
|
|
242
|
-
pd.DataFrame(
|
|
243
|
-
[
|
|
244
|
-
{
|
|
245
|
-
"Table Name": r["Table Name"],
|
|
246
|
-
"Object Name": r["Object Name"],
|
|
247
|
-
"Object Type": r["Object Type"],
|
|
248
|
-
"Referenced Object": dependency.iloc[5],
|
|
249
|
-
"Referenced Table": dependency.iloc[4],
|
|
250
|
-
"Referenced Object Type": dependency.iloc[
|
|
251
|
-
6
|
|
252
|
-
],
|
|
253
|
-
"Done": d,
|
|
254
|
-
"Full Object Name": r["Full Object Name"],
|
|
255
|
-
"Referenced Full Object Name": dependency.iloc[
|
|
256
|
-
7
|
|
257
|
-
],
|
|
258
|
-
"Parent Node": rObj,
|
|
259
|
-
}
|
|
260
|
-
]
|
|
261
|
-
),
|
|
262
|
-
],
|
|
263
|
-
ignore_index=True,
|
|
264
|
-
)
|
|
265
|
-
|
|
266
|
-
df.loc[i, "Done"] = True
|
|
267
|
-
|
|
268
|
-
df = df.drop(["Done"], axis=1)
|
|
190
|
+
# Initialize dependency DataFrame with 'Done' status
|
|
191
|
+
df = dep.copy()
|
|
192
|
+
objs = {"Measure", "Calc Column", "Calculation Item", "Calc Table"}
|
|
193
|
+
df["Done"] = df["Referenced Object Type"].apply(lambda x: x not in objs)
|
|
194
|
+
# Expand dependencies iteratively
|
|
195
|
+
while not df["Done"].all():
|
|
196
|
+
incomplete_rows = df[df["Done"] == False]
|
|
197
|
+
for _, row in incomplete_rows.iterrows():
|
|
198
|
+
referenced_full_name = row["Referenced Full Object Name"]
|
|
199
|
+
dep_filt = dep[dep["Full Object Name"] == referenced_full_name]
|
|
200
|
+
# Expand dependencies and update 'Done' status as needed
|
|
201
|
+
new_rows = []
|
|
202
|
+
for _, dependency in dep_filt.iterrows():
|
|
203
|
+
is_done = dependency["Referenced Object Type"] not in objs
|
|
204
|
+
new_row = {
|
|
205
|
+
"Table Name": row["Table Name"],
|
|
206
|
+
"Object Name": row["Object Name"],
|
|
207
|
+
"Object Type": row["Object Type"],
|
|
208
|
+
"Referenced Table": dependency["Referenced Table"],
|
|
209
|
+
"Referenced Object": dependency["Referenced Object"],
|
|
210
|
+
"Referenced Object Type": dependency["Referenced Object Type"],
|
|
211
|
+
"Done": is_done,
|
|
212
|
+
"Full Object Name": row["Full Object Name"],
|
|
213
|
+
"Referenced Full Object Name": dependency[
|
|
214
|
+
"Referenced Full Object Name"
|
|
215
|
+
],
|
|
216
|
+
"Parent Node": row["Referenced Object"],
|
|
217
|
+
}
|
|
218
|
+
new_rows.append(new_row)
|
|
219
|
+
df = pd.concat([df, pd.DataFrame(new_rows)], ignore_index=True)
|
|
220
|
+
df.loc[df.index == row.name, "Done"] = True
|
|
221
|
+
# Finalize DataFrame and yield result
|
|
222
|
+
df = df.drop(columns=["Done"])
|
|
269
223
|
|
|
270
224
|
return df
|
|
271
225
|
|
sempy_labs/_notebooks.py
CHANGED
|
@@ -18,6 +18,8 @@ def get_notebook_definition(
|
|
|
18
18
|
"""
|
|
19
19
|
Obtains the notebook definition.
|
|
20
20
|
|
|
21
|
+
This is a wrapper function for the following API: `Items - Get Notebook Definition <https://learn.microsoft.com/rest/api/fabric/notebook/items/get-notebook-definition>`_.
|
|
22
|
+
|
|
21
23
|
Parameters
|
|
22
24
|
----------
|
|
23
25
|
notebook_name : str
|
|
@@ -63,6 +65,7 @@ def import_notebook_from_web(
|
|
|
63
65
|
url: str,
|
|
64
66
|
description: Optional[str] = None,
|
|
65
67
|
workspace: Optional[str] = None,
|
|
68
|
+
overwrite: bool = False,
|
|
66
69
|
):
|
|
67
70
|
"""
|
|
68
71
|
Creates a new notebook within a workspace based on a Jupyter notebook hosted in the web.
|
|
@@ -83,16 +86,12 @@ def import_notebook_from_web(
|
|
|
83
86
|
The name of the workspace.
|
|
84
87
|
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
85
88
|
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
89
|
+
overwrite : bool, default=False
|
|
90
|
+
If set to True, overwrites the existing notebook in the workspace if it exists.
|
|
86
91
|
"""
|
|
87
92
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
dfI = fabric.list_items(workspace=workspace, type="Notebook")
|
|
91
|
-
dfI_filt = dfI[dfI["Display Name"] == notebook_name]
|
|
92
|
-
if len(dfI_filt) > 0:
|
|
93
|
-
raise ValueError(
|
|
94
|
-
f"{icons.red_dot} The '{notebook_name}' already exists within the '{workspace}' workspace."
|
|
95
|
-
)
|
|
93
|
+
if workspace is None:
|
|
94
|
+
workspace = fabric.resolve_workspace_name(workspace)
|
|
96
95
|
|
|
97
96
|
# Fix links to go to the raw github file
|
|
98
97
|
starting_text = "https://github.com/"
|
|
@@ -105,11 +104,56 @@ def import_notebook_from_web(
|
|
|
105
104
|
response = requests.get(url)
|
|
106
105
|
if response.status_code != 200:
|
|
107
106
|
raise FabricHTTPException(response)
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
|
|
108
|
+
dfI = fabric.list_items(workspace=workspace, type="Notebook")
|
|
109
|
+
dfI_filt = dfI[dfI["Display Name"] == notebook_name]
|
|
110
|
+
if len(dfI_filt) == 0:
|
|
111
|
+
create_notebook(
|
|
112
|
+
name=notebook_name,
|
|
113
|
+
notebook_content=response.content,
|
|
114
|
+
workspace=workspace,
|
|
115
|
+
description=description,
|
|
116
|
+
)
|
|
117
|
+
elif len(dfI_filt) > 0 and overwrite:
|
|
118
|
+
update_notebook_definition(
|
|
119
|
+
name=notebook_name, notebook_content=response.content, workspace=workspace
|
|
120
|
+
)
|
|
121
|
+
else:
|
|
122
|
+
raise ValueError(
|
|
123
|
+
f"{icons.red_dot} The '{notebook_name}' already exists within the '{workspace}' workspace and 'overwrite' is set to False."
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def create_notebook(
|
|
128
|
+
name: str,
|
|
129
|
+
notebook_content: str,
|
|
130
|
+
description: Optional[str] = None,
|
|
131
|
+
workspace: Optional[str] = None,
|
|
132
|
+
):
|
|
133
|
+
"""
|
|
134
|
+
Creates a new notebook with a definition within a workspace.
|
|
135
|
+
|
|
136
|
+
Parameters
|
|
137
|
+
----------
|
|
138
|
+
name : str
|
|
139
|
+
The name of the notebook to be created.
|
|
140
|
+
notebook_content : str
|
|
141
|
+
The Jupyter notebook content (not in Base64 format).
|
|
142
|
+
description : str, default=None
|
|
143
|
+
The description of the notebook.
|
|
144
|
+
Defaults to None which does not place a description.
|
|
145
|
+
workspace : str, default=None
|
|
146
|
+
The name of the workspace.
|
|
147
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
148
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
(workspace, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
152
|
+
client = fabric.FabricRestClient()
|
|
153
|
+
notebook_payload = base64.b64encode(notebook_content)
|
|
110
154
|
|
|
111
155
|
request_body = {
|
|
112
|
-
"displayName":
|
|
156
|
+
"displayName": name,
|
|
113
157
|
"definition": {
|
|
114
158
|
"format": "ipynb",
|
|
115
159
|
"parts": [
|
|
@@ -129,5 +173,56 @@ def import_notebook_from_web(
|
|
|
129
173
|
lro(client, response, status_codes=[201, 202])
|
|
130
174
|
|
|
131
175
|
print(
|
|
132
|
-
f"{icons.green_dot} The '{
|
|
176
|
+
f"{icons.green_dot} The '{name}' notebook was created within the '{workspace}' workspace."
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def update_notebook_definition(
|
|
181
|
+
name: str, notebook_content: str, workspace: Optional[str] = None
|
|
182
|
+
):
|
|
183
|
+
"""
|
|
184
|
+
Updates an existing notebook with a new definition.
|
|
185
|
+
|
|
186
|
+
Parameters
|
|
187
|
+
----------
|
|
188
|
+
name : str
|
|
189
|
+
The name of the notebook to be updated.
|
|
190
|
+
notebook_content : str
|
|
191
|
+
The Jupyter notebook content (not in Base64 format).
|
|
192
|
+
workspace : str, default=None
|
|
193
|
+
The name of the workspace.
|
|
194
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
195
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
196
|
+
"""
|
|
197
|
+
|
|
198
|
+
(workspace, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
199
|
+
client = fabric.FabricRestClient()
|
|
200
|
+
notebook_payload = base64.b64encode(notebook_content)
|
|
201
|
+
notebook_id = fabric.resolve_item_id(
|
|
202
|
+
item_name=name, type="Notebook", workspace=workspace
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
request_body = {
|
|
206
|
+
"displayName": name,
|
|
207
|
+
"definition": {
|
|
208
|
+
"format": "ipynb",
|
|
209
|
+
"parts": [
|
|
210
|
+
{
|
|
211
|
+
"path": "notebook-content.py",
|
|
212
|
+
"payload": notebook_payload,
|
|
213
|
+
"payloadType": "InlineBase64",
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
},
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
response = client.post(
|
|
220
|
+
f"v1/workspaces/{workspace_id}/notebooks/{notebook_id}/updateDefinition",
|
|
221
|
+
json=request_body,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
lro(client, response, return_status_code=True)
|
|
225
|
+
|
|
226
|
+
print(
|
|
227
|
+
f"{icons.green_dot} The '{name}' notebook was updated within the '{workspace}' workspace."
|
|
133
228
|
)
|
sempy_labs/_query_scale_out.py
CHANGED
|
@@ -13,6 +13,8 @@ def qso_sync(dataset: str, workspace: Optional[str] = None):
|
|
|
13
13
|
"""
|
|
14
14
|
Triggers a query scale-out sync of read-only replicas for the specified dataset from the specified workspace.
|
|
15
15
|
|
|
16
|
+
This is a wrapper function for the following API: `Datasets - Trigger Query Scale Out Sync In Group <https://learn.microsoft.com/rest/api/power-bi/datasets/trigger-query-scale-out-sync-in-group>`_.
|
|
17
|
+
|
|
16
18
|
Parameters
|
|
17
19
|
----------
|
|
18
20
|
dataset : str
|
|
@@ -23,8 +25,6 @@ def qso_sync(dataset: str, workspace: Optional[str] = None):
|
|
|
23
25
|
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
24
26
|
"""
|
|
25
27
|
|
|
26
|
-
# https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/trigger-query-scale-out-sync-in-group
|
|
27
|
-
|
|
28
28
|
(workspace, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
29
29
|
dataset_id = resolve_dataset_id(dataset, workspace)
|
|
30
30
|
|
|
@@ -46,6 +46,8 @@ def qso_sync_status(
|
|
|
46
46
|
"""
|
|
47
47
|
Returns the query scale-out sync status for the specified dataset from the specified workspace.
|
|
48
48
|
|
|
49
|
+
This is a wrapper function for the following API: `Datasets - Get Query Scale Out Sync Status In Group <https://learn.microsoft.com/rest/api/power-bi/datasets/get-query-scale-out-sync-status-in-group>`_.
|
|
50
|
+
|
|
49
51
|
Parameters
|
|
50
52
|
----------
|
|
51
53
|
dataset : str
|
|
@@ -61,8 +63,6 @@ def qso_sync_status(
|
|
|
61
63
|
2 pandas dataframes showing the query scale-out sync status.
|
|
62
64
|
"""
|
|
63
65
|
|
|
64
|
-
# https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/get-query-scale-out-sync-status-in-group
|
|
65
|
-
|
|
66
66
|
df = pd.DataFrame(
|
|
67
67
|
columns=[
|
|
68
68
|
"Scale Out Status",
|
|
@@ -143,6 +143,8 @@ def disable_qso(dataset: str, workspace: Optional[str] = None) -> pd.DataFrame:
|
|
|
143
143
|
"""
|
|
144
144
|
Sets the max read-only replicas to 0, disabling query scale out.
|
|
145
145
|
|
|
146
|
+
This is a wrapper function for the following API: `Datasets - Update Dataset In Group <https://learn.microsoft.com/rest/api/power-bi/datasets/update-dataset-in-group>`_.
|
|
147
|
+
|
|
146
148
|
Parameters
|
|
147
149
|
----------
|
|
148
150
|
dataset : str
|
|
@@ -188,6 +190,8 @@ def set_qso(
|
|
|
188
190
|
"""
|
|
189
191
|
Sets the query scale out settings for a semantic model.
|
|
190
192
|
|
|
193
|
+
This is a wrapper function for the following API: `Datasets - Update Dataset In Group <https://learn.microsoft.com/rest/api/power-bi/datasets/update-dataset-in-group>`_.
|
|
194
|
+
|
|
191
195
|
Parameters
|
|
192
196
|
----------
|
|
193
197
|
dataset : str
|
|
@@ -209,8 +213,6 @@ def set_qso(
|
|
|
209
213
|
|
|
210
214
|
from sempy_labs._helper_functions import is_default_semantic_model
|
|
211
215
|
|
|
212
|
-
# https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/update-dataset-in-group
|
|
213
|
-
|
|
214
216
|
(workspace, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
215
217
|
dataset_id = resolve_dataset_id(dataset, workspace)
|
|
216
218
|
|