semantic-link-labs 0.11.2__py3-none-any.whl → 0.11.3__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.

Files changed (29) hide show
  1. {semantic_link_labs-0.11.2.dist-info → semantic_link_labs-0.11.3.dist-info}/METADATA +4 -4
  2. {semantic_link_labs-0.11.2.dist-info → semantic_link_labs-0.11.3.dist-info}/RECORD +26 -24
  3. sempy_labs/__init__.py +12 -18
  4. sempy_labs/_a_lib_info.py +1 -1
  5. sempy_labs/_external_data_shares.py +55 -1
  6. sempy_labs/_helper_functions.py +169 -5
  7. sempy_labs/_labels.py +126 -0
  8. sempy_labs/_list_functions.py +1 -1
  9. sempy_labs/_notebooks.py +152 -3
  10. sempy_labs/directlake/_dl_helper.py +4 -1
  11. sempy_labs/graph/_users.py +3 -5
  12. sempy_labs/lakehouse/_helper.py +18 -9
  13. sempy_labs/lakehouse/_lakehouse.py +18 -9
  14. sempy_labs/migration/_migrate_calctables_to_lakehouse.py +38 -47
  15. sempy_labs/migration/_migrate_calctables_to_semantic_model.py +12 -22
  16. sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +7 -11
  17. sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +14 -23
  18. sempy_labs/ml_model/__init__.py +23 -0
  19. sempy_labs/ml_model/_functions.py +427 -0
  20. sempy_labs/report/_reportwrapper.py +1 -1
  21. sempy_labs/tom/_model.py +8 -3
  22. sempy_labs/variable_library/__init__.py +19 -0
  23. sempy_labs/variable_library/_functions.py +403 -0
  24. sempy_labs/_dax_query_view.py +0 -57
  25. sempy_labs/_ml_models.py +0 -111
  26. sempy_labs/_variable_libraries.py +0 -92
  27. {semantic_link_labs-0.11.2.dist-info → semantic_link_labs-0.11.3.dist-info}/WHEEL +0 -0
  28. {semantic_link_labs-0.11.2.dist-info → semantic_link_labs-0.11.3.dist-info}/licenses/LICENSE +0 -0
  29. {semantic_link_labs-0.11.2.dist-info → semantic_link_labs-0.11.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,403 @@
1
+ from sempy_labs._helper_functions import (
2
+ resolve_item_id,
3
+ resolve_workspace_id,
4
+ _base_api,
5
+ _create_dataframe,
6
+ _update_dataframe_datatypes,
7
+ delete_item,
8
+ _decode_b64,
9
+ )
10
+ import pandas as pd
11
+ from typing import Any, Optional, List, Union
12
+ from uuid import UUID
13
+ from sempy._utils._log import log
14
+ import json
15
+ import sempy_labs._icons as icons
16
+
17
+
18
+ @log
19
+ def get_variable_library(
20
+ variable_library: str | UUID, workspace: Optional[str | UUID] = None
21
+ ) -> pd.DataFrame:
22
+ """
23
+ Returns properties of the specified variable library.
24
+
25
+ This is a wrapper function for the following API: `Items - Get Variable Library <https://learn.microsoft.com/rest/api/fabric/variablelibrary/items/get-variable-library>`_.
26
+
27
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
28
+
29
+ Parameters
30
+ ----------
31
+ variable_library : str | uuid.UUID
32
+ Name or ID of the variable library.
33
+ workspace : str | uuid.UUID, default=None
34
+ The Fabric workspace name or ID.
35
+ Defaults to None which resolves to the workspace of the attached lakehouse
36
+ or if no lakehouse attached, resolves to the workspace of the notebook.
37
+
38
+ Returns
39
+ -------
40
+ pandas.DataFrame
41
+ A pandas dataframe showing the properties of the variable library.
42
+ """
43
+
44
+ columns = {
45
+ "Variable Library Name": "string",
46
+ "Variable Library Id": "string",
47
+ "Description": "string",
48
+ "Active Value Set Name": "string",
49
+ }
50
+ df = _create_dataframe(columns=columns)
51
+
52
+ workspace_id = resolve_workspace_id(workspace)
53
+ variable_library_id = resolve_item_id(
54
+ item=variable_library, type="VariableLibrary", workspace=workspace
55
+ )
56
+
57
+ response = _base_api(
58
+ request=f"/v1/workspaces/{workspace_id}/variableLibraries/{variable_library_id}",
59
+ client="fabric_sp",
60
+ )
61
+
62
+ result = response.json()
63
+ prop = result.get("properties", {})
64
+
65
+ if prop:
66
+ df = pd.DataFrame(
67
+ [
68
+ {
69
+ "Variable Library Name": result.get("displayName"),
70
+ "Variable Library Id": result.get("id"),
71
+ "Description": result.get("description"),
72
+ "Active Value Set Name": prop.get("activeValueSetName"),
73
+ }
74
+ ],
75
+ columns=list(columns.keys()),
76
+ )
77
+
78
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
79
+
80
+ return df
81
+
82
+
83
+ @log
84
+ def list_variable_libraries(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
85
+ """
86
+ Shows the variable libraries within a workspace.
87
+
88
+ This is a wrapper function for the following API: `Items - List Variable Libraries <https://learn.microsoft.com/rest/api/fabric/variablelibrary/items/list-variable-libraries>`_.
89
+
90
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
91
+
92
+ Parameters
93
+ ----------
94
+ workspace : str | uuid.UUID, default=None
95
+ The Fabric workspace name or ID.
96
+ Defaults to None which resolves to the workspace of the attached lakehouse
97
+ or if no lakehouse attached, resolves to the workspace of the notebook.
98
+
99
+ Returns
100
+ -------
101
+ pandas.DataFrame
102
+ A pandas dataframe showing the variable libraries within a workspace.
103
+ """
104
+
105
+ columns = {
106
+ "Variable Library Name": "string",
107
+ "Variable Library Id": "string",
108
+ "Description": "string",
109
+ "Active Value Set Name": "string",
110
+ }
111
+ df = _create_dataframe(columns=columns)
112
+
113
+ workspace_id = resolve_workspace_id(workspace)
114
+
115
+ responses = _base_api(
116
+ request=f"/v1/workspaces/{workspace_id}/VariableLibraries",
117
+ uses_pagination=True,
118
+ client="fabric_sp",
119
+ )
120
+
121
+ rows = []
122
+ for r in responses:
123
+ for v in r.get("value", []):
124
+ prop = v.get("properties", {})
125
+
126
+ rows.append(
127
+ {
128
+ "Variable Library Name": v.get("displayName"),
129
+ "Variable Library Id": v.get("id"),
130
+ "Description": v.get("description"),
131
+ "Active Value Set Name": prop.get("activeValueSetName"),
132
+ }
133
+ )
134
+
135
+ if rows:
136
+ df = pd.DataFrame(rows, columns=list(columns.keys()))
137
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
138
+
139
+ return df
140
+
141
+
142
+ @log
143
+ def delete_variable_library(
144
+ variable_library: str | UUID, workspace: Optional[str | UUID] = None
145
+ ):
146
+ """
147
+ Deletes a variable library.
148
+
149
+ This is a wrapper function for the following API: `Items - Delete Variable Library https://learn.microsoft.com/rest/api/fabric/variablelibrary/items/delete-variable-library>`_.
150
+
151
+ Parameters
152
+ ----------
153
+ navariable_libraryme: str | uuid.UUID
154
+ Name or ID of the variable library.
155
+ workspace : str | uuid.UUID, default=None
156
+ The Fabric workspace name or ID.
157
+ Defaults to None which resolves to the workspace of the attached lakehouse
158
+ or if no lakehouse attached, resolves to the workspace of the notebook.
159
+ """
160
+
161
+ delete_item(item=variable_library, type="VariableLibrary", workspace=workspace)
162
+
163
+
164
+ @log
165
+ def get_variable_library_definition(
166
+ variable_library: str | UUID,
167
+ workspace: Optional[str | UUID] = None,
168
+ decode: bool = True,
169
+ return_dataframe: bool = False,
170
+ ) -> dict | pd.DataFrame:
171
+ """
172
+ Gets the definition of a variable library.
173
+
174
+ This is a wrapper function for the following API: `Items - Get Variable Library Definition <https://learn.microsoft.com/rest/api/fabric/variablelibrary/items/delete-variable-library>`_.
175
+
176
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
177
+
178
+ Parameters
179
+ ----------
180
+ workspace : str | uuid.UUID, default=None
181
+ The Fabric workspace name or ID.
182
+ Defaults to None which resolves to the workspace of the attached lakehouse
183
+ or if no lakehouse attached, resolves to the workspace of the notebook.
184
+
185
+ Returns
186
+ -------
187
+ dict | pandas.DataFrame
188
+ A dictionary showing the definition or a pandas dataframe showing the definition.
189
+ """
190
+
191
+ workspace_id = resolve_workspace_id(workspace)
192
+ variable_library_id = resolve_item_id(
193
+ item=variable_library, type="VariableLibrary", workspace=workspace
194
+ )
195
+
196
+ result = _base_api(
197
+ request=f"/v1/workspaces/{workspace_id}/variableLibraries/{variable_library_id}/getDefinition",
198
+ method="post",
199
+ client="fabric_sp",
200
+ status_codes=None,
201
+ lro_return_json=True,
202
+ )
203
+
204
+ if decode:
205
+ definition = {"definition": {"parts": []}}
206
+
207
+ for part in result.get("definition", {}).get("parts", []):
208
+ path = part.get("path")
209
+ payload = _decode_b64(part.get("payload"))
210
+ definition["definition"]["parts"].append({"path": path, "payload": payload})
211
+ else:
212
+ definition = result.copy()
213
+
214
+ if return_dataframe:
215
+ df = pd.DataFrame(definition["definition"]["parts"])
216
+ df.columns = ["Path", "Payload", "Payload Type"]
217
+ return df
218
+ else:
219
+ return definition
220
+
221
+
222
+ @log
223
+ def list_variables(
224
+ variable_library: str | UUID, workspace: Optional[str | UUID] = None
225
+ ) -> pd.DataFrame:
226
+ """
227
+ Lists the variables in a variable library.
228
+
229
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
230
+
231
+ Parameters
232
+ ----------
233
+ variable_library : str | uuid.UUID
234
+ Name or ID of the variable library.
235
+ workspace : str | uuid.UUID, default=None
236
+ The Fabric workspace name or ID.
237
+ Defaults to None which resolves to the workspace of the attached lakehouse
238
+ or if no lakehouse attached, resolves to the workspace of the notebook.
239
+
240
+ Returns
241
+ -------
242
+ pandas.DataFrame
243
+ A pandas dataframe showing the variables within a variable library.
244
+ """
245
+
246
+ result = get_variable_library_definition(
247
+ variable_library=variable_library,
248
+ workspace=workspace,
249
+ decode=True,
250
+ return_dataframe=False,
251
+ )
252
+
253
+ columns = {
254
+ "Variable Name": "string",
255
+ "Note": "string",
256
+ "Type": "string",
257
+ "Value": "string",
258
+ }
259
+
260
+ df = _create_dataframe(columns=columns)
261
+
262
+ rows = []
263
+ for part in result.get("definition").get("parts"):
264
+ path = part.get("path")
265
+ payload = json.loads(part.get("payload"))
266
+ if path == "variables.json":
267
+
268
+ for variable in payload.get("variables", []):
269
+ rows.append(
270
+ {
271
+ "Variable Name": variable.get("name"),
272
+ "Note": variable.get("note"),
273
+ "Type": variable.get("type"),
274
+ "Value": variable.get("value"),
275
+ }
276
+ )
277
+
278
+ if rows:
279
+ df = pd.DataFrame(rows, columns=list(columns.keys()))
280
+
281
+ for part in result.get("definition", {}).get("parts", []):
282
+ path = part.get("path")
283
+ if path.startswith("valueSets") and path.endswith(".json"):
284
+ payload = json.loads(part.get("payload"))
285
+ value_set_name = payload.get("name")
286
+
287
+ # Initialize the new column with None (or pd.NA)
288
+ df[value_set_name] = None
289
+
290
+ for override in payload.get("variableOverrides", []):
291
+ variable_name = override.get("name")
292
+ variable_value = override.get("value")
293
+
294
+ # Set the value in the appropriate row and column
295
+ df.loc[df["Variable Name"] == variable_name, value_set_name] = (
296
+ variable_value
297
+ )
298
+
299
+ return df
300
+
301
+
302
+ @log
303
+ def get_variable_values(
304
+ variable_names: List[str],
305
+ variable_library: Union[str, UUID],
306
+ workspace: Optional[Union[str, UUID]] = None,
307
+ value_set: Optional[str] = None,
308
+ ) -> dict:
309
+ """
310
+ Gets the values of multiple variables from a variable library with a single call to list_variables.
311
+
312
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
313
+
314
+ Parameters
315
+ ----------
316
+ variable_names : List[str]
317
+ A list of variable names to retrieve.
318
+ variable_library : str | uuid.UUID
319
+ Name or ID of the variable library.
320
+ workspace : str | uuid.UUID, default=None
321
+ The Fabric workspace name or ID.
322
+ Defaults to None which resolves to the workspace of the attached lakehouse
323
+ or if no lakehouse attached, resolves to the workspace of the notebook.
324
+ value_set : str, default=None
325
+ The name of the value set to use for variable overrides.
326
+ If None, the active value set of the variable library will be used.
327
+
328
+ Returns
329
+ -------
330
+ dict
331
+ Dictionary mapping variable names to their corresponding values.
332
+ """
333
+
334
+ if isinstance(variable_names, str):
335
+ variable_names = [variable_names]
336
+
337
+ if value_set is None:
338
+ vl_df = get_variable_library(
339
+ variable_library=variable_library, workspace=workspace
340
+ )
341
+ if vl_df.empty:
342
+ raise ValueError(
343
+ f"{icons.red_dot} The variable library '{variable_library}' does not exist within the '{workspace}' workspace."
344
+ )
345
+ value_set = vl_df["Active Value Set Name"].iloc[0]
346
+
347
+ df = list_variables(variable_library=variable_library, workspace=workspace)
348
+ found_variables = df[df["Variable Name"].isin(variable_names)]
349
+
350
+ missing = set(variable_names) - set(found_variables["Variable Name"])
351
+ if missing:
352
+ raise ValueError(
353
+ f"{icons.red_dot} The following variables do not exist in the '{variable_library}' variable library: {', '.join(missing)}"
354
+ )
355
+
356
+ if value_set == "Default value set":
357
+ value_set = "Value"
358
+ if value_set not in df.columns:
359
+ raise ValueError(
360
+ f"{icons.red_dot} The value set '{value_set}' does not exist in the variable library '{variable_library}' within the '{workspace}' workspace."
361
+ )
362
+
363
+ return dict(zip(found_variables["Variable Name"], found_variables[value_set]))
364
+
365
+
366
+ @log
367
+ def get_variable_value(
368
+ variable_name: str,
369
+ variable_library: str | UUID,
370
+ workspace: Optional[str | UUID] = None,
371
+ value_set: Optional[str] = None,
372
+ ) -> Any:
373
+ """
374
+ Gets the value of a single variable in a variable library.
375
+
376
+ Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
377
+
378
+ Parameters
379
+ ----------
380
+ variable_name : str
381
+ Name of the variable.
382
+ variable_library : str | uuid.UUID
383
+ Name or ID of the variable library.
384
+ workspace : str | uuid.UUID, default=None
385
+ The Fabric workspace name or ID.
386
+ Defaults to None which resolves to the workspace of the attached lakehouse
387
+ or if no lakehouse attached, resolves to the workspace of the notebook.
388
+ value_set : str, default=None
389
+ The name of the value set to use for variable overrides.
390
+ If None, the active value set of the variable library will be used.
391
+
392
+ Returns
393
+ -------
394
+ Any
395
+ The value of the variable.
396
+ """
397
+
398
+ return get_variable_values(
399
+ variable_names=[variable_name],
400
+ variable_library=variable_library,
401
+ workspace=workspace,
402
+ value_set=value_set,
403
+ )[variable_name]
@@ -1,57 +0,0 @@
1
- from typing import Optional
2
- from uuid import UUID
3
- from ._helper_functions import (
4
- resolve_dataset_id,
5
- _get_fabric_context_setting,
6
- resolve_workspace_id,
7
- )
8
- from sempy._utils._log import log
9
- import gzip
10
- import base64
11
- import urllib.parse
12
-
13
-
14
- @log
15
- def generate_dax_query_view_url(
16
- dataset: str | UUID, dax_string: str, workspace: Optional[str | UUID] = None
17
- ):
18
- """
19
- Prints a URL based on query provided. This URL opens `DAX query view <https://learn.microsoft.com/power-bi/transform-model/dax-query-view>`_ in the Power BI service, connected to the semantic model and using the query provided.
20
-
21
- Parameters
22
- ----------
23
- dataset : str | uuid.UUID
24
- The semantic model name or ID.
25
- dax_string : str
26
- The DAX query string.
27
- workspace : str | uuid.UUID, default=None
28
- The workspace name or ID.
29
- Defaults to None which resolves to the workspace of the attached lakehouse
30
- or if no lakehouse attached, resolves to the workspace of the notebook.
31
- """
32
-
33
- workspace_id = resolve_workspace_id(workspace=workspace)
34
- dataset_id = resolve_dataset_id(dataset=dataset, workspace=workspace_id)
35
-
36
- prefix = _get_fabric_context_setting(name="spark.trident.pbienv").lower()
37
-
38
- if prefix == "prod":
39
- prefix = "app"
40
-
41
- def gzip_base64_urlsafe(input_string):
42
- # Compress the string with gzip
43
- compressed_data = gzip.compress(input_string.encode("utf-8"))
44
-
45
- # Encode the compressed data in base64
46
- base64_data = base64.b64encode(compressed_data)
47
-
48
- # Make the base64 string URL-safe
49
- urlsafe_data = urllib.parse.quote_plus(base64_data.decode("utf-8"))
50
-
51
- return urlsafe_data
52
-
53
- formatted_query = gzip_base64_urlsafe(dax_string)
54
-
55
- url = f"https://{prefix}.powerbi.com/groups/{workspace_id}/modeling/{dataset_id}/daxQueryView?query={formatted_query}"
56
-
57
- print(url)
sempy_labs/_ml_models.py DELETED
@@ -1,111 +0,0 @@
1
- import pandas as pd
2
- from typing import Optional
3
- from ._helper_functions import (
4
- resolve_workspace_id,
5
- _base_api,
6
- delete_item,
7
- _create_dataframe,
8
- create_item,
9
- )
10
- from uuid import UUID
11
- from sempy._utils._log import log
12
-
13
-
14
- @log
15
- def list_ml_models(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
16
- """
17
- Shows the ML models within a workspace.
18
-
19
- This is a wrapper function for the following API: `Items - List ML Models <https://learn.microsoft.com/rest/api/fabric/mlmodel/items/list-ml-models>`_.
20
-
21
- Parameters
22
- ----------
23
- workspace : str | uuid.UUID, default=None
24
- The Fabric workspace name or ID.
25
- Defaults to None which resolves to the workspace of the attached lakehouse
26
- or if no lakehouse attached, resolves to the workspace of the notebook.
27
-
28
- Returns
29
- -------
30
- pandas.DataFrame
31
- A pandas dataframe showing the ML models within a workspace.
32
- """
33
-
34
- columns = {
35
- "ML Model Name": "string",
36
- "ML Model Id": "string",
37
- "Description": "string",
38
- }
39
- df = _create_dataframe(columns=columns)
40
-
41
- workspace_id = resolve_workspace_id(workspace)
42
-
43
- responses = _base_api(
44
- request=f"/v1/workspaces/{workspace_id}/mlModels",
45
- status_codes=200,
46
- uses_pagination=True,
47
- )
48
-
49
- rows = []
50
- for r in responses:
51
- for v in r.get("value", []):
52
- model_id = v.get("id")
53
- modelName = v.get("displayName")
54
- desc = v.get("description")
55
-
56
- rows.append(
57
- {
58
- "ML Model Name": modelName,
59
- "ML Model Id": model_id,
60
- "Description": desc,
61
- }
62
- )
63
-
64
- if rows:
65
- df = pd.DataFrame(rows, columns=list(columns.keys()))
66
-
67
- return df
68
-
69
-
70
- @log
71
- def create_ml_model(
72
- name: str, description: Optional[str] = None, workspace: Optional[str | UUID] = None
73
- ):
74
- """
75
- Creates a Fabric ML model.
76
-
77
- This is a wrapper function for the following API: `Items - Create ML Model <https://learn.microsoft.com/rest/api/fabric/mlmodel/items/create-ml-model>`_.
78
-
79
- Parameters
80
- ----------
81
- name: str
82
- Name of the ML model.
83
- description : str, default=None
84
- A description of the ML model.
85
- workspace : str | uuid.UUID, default=None
86
- The Fabric workspace name or ID.
87
- Defaults to None which resolves to the workspace of the attached lakehouse
88
- or if no lakehouse attached, resolves to the workspace of the notebook.
89
- """
90
-
91
- create_item(name=name, description=description, type="MLModel", workspace=workspace)
92
-
93
-
94
- @log
95
- def delete_ml_model(name: str | UUID, workspace: Optional[str | UUID] = None):
96
- """
97
- Deletes a Fabric ML model.
98
-
99
- This is a wrapper function for the following API: `Items - Delete ML Model <https://learn.microsoft.com/rest/api/fabric/mlmodel/items/delete-ml-model>`_.
100
-
101
- Parameters
102
- ----------
103
- name: str | uuid.UUID
104
- Name or ID of the ML model.
105
- workspace : str | uuid.UUID, default=None
106
- The Fabric workspace name or ID.
107
- Defaults to None which resolves to the workspace of the attached lakehouse
108
- or if no lakehouse attached, resolves to the workspace of the notebook.
109
- """
110
-
111
- delete_item(item=name, type="MLModel", workspace=workspace)
@@ -1,92 +0,0 @@
1
- from ._helper_functions import (
2
- resolve_workspace_id,
3
- _base_api,
4
- _create_dataframe,
5
- _update_dataframe_datatypes,
6
- delete_item,
7
- )
8
- import pandas as pd
9
- from typing import Optional
10
- from uuid import UUID
11
- from sempy._utils._log import log
12
-
13
-
14
- @log
15
- def list_variable_libraries(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
16
- """
17
- Shows the variable libraries within a workspace.
18
-
19
- This is a wrapper function for the following API: `Items - List Variable Libraries <https://learn.microsoft.com/rest/api/fabric/variablelibrary/items/list-variable-libraries>`_.
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
-
23
- Parameters
24
- ----------
25
- workspace : str | uuid.UUID, default=None
26
- The Fabric workspace name or ID.
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
-
30
- Returns
31
- -------
32
- pandas.DataFrame
33
- A pandas dataframe showing the variable libraries within a workspace.
34
- """
35
-
36
- columns = {
37
- "Variable Library Name": "string",
38
- "Variable Library Id": "string",
39
- "Description": "string",
40
- "Active Value Set Name": "string",
41
- }
42
- df = _create_dataframe(columns=columns)
43
-
44
- workspace_id = resolve_workspace_id(workspace)
45
-
46
- responses = _base_api(
47
- request=f"/v1/workspaces/{workspace_id}/VariableLibraries",
48
- uses_pagination=True,
49
- client="fabric_sp",
50
- )
51
-
52
- rows = []
53
- for r in responses:
54
- for v in r.get("value", []):
55
- prop = v.get("properties", {})
56
-
57
- rows.append(
58
- {
59
- "Variable Library Name": v.get("displayName"),
60
- "Variable Library Id": v.get("id"),
61
- "Description": v.get("description"),
62
- "Active Value Set Name": prop.get("activeValueSetName"),
63
- }
64
- )
65
-
66
- if rows:
67
- df = pd.DataFrame(rows, columns=list(columns.keys()))
68
- _update_dataframe_datatypes(dataframe=df, column_map=columns)
69
-
70
- return df
71
-
72
-
73
- @log
74
- def delete_variable_library(
75
- variable_library: str | UUID, workspace: Optional[str | UUID] = None
76
- ):
77
- """
78
- Deletes a variable library.
79
-
80
- This is a wrapper function for the following API: `Items - Delete Variable Library <https://learn.microsoft.com/rest/api/fabric/warehouse/items/delete-variable-library>`_.
81
-
82
- Parameters
83
- ----------
84
- navariable_libraryme: str | uuid.UUID
85
- Name or ID of the variable library.
86
- workspace : str | uuid.UUID, default=None
87
- The Fabric workspace name or ID.
88
- Defaults to None which resolves to the workspace of the attached lakehouse
89
- or if no lakehouse attached, resolves to the workspace of the notebook.
90
- """
91
-
92
- delete_item(item=variable_library, type="VariableLibrary", workspace=workspace)