semantic-link-labs 0.9.1__py3-none-any.whl → 0.9.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 (87) hide show
  1. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.3.dist-info}/METADATA +67 -8
  2. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.3.dist-info}/RECORD +87 -80
  3. sempy_labs/__init__.py +14 -12
  4. sempy_labs/_ai.py +8 -5
  5. sempy_labs/_capacities.py +120 -142
  6. sempy_labs/_capacity_migration.py +61 -94
  7. sempy_labs/_clear_cache.py +9 -8
  8. sempy_labs/_connections.py +107 -104
  9. sempy_labs/_data_pipelines.py +47 -49
  10. sempy_labs/_dataflows.py +45 -51
  11. sempy_labs/_dax.py +228 -6
  12. sempy_labs/_delta_analyzer.py +321 -0
  13. sempy_labs/_deployment_pipelines.py +72 -66
  14. sempy_labs/_environments.py +39 -36
  15. sempy_labs/_eventhouses.py +35 -35
  16. sempy_labs/_eventstreams.py +38 -39
  17. sempy_labs/_external_data_shares.py +29 -42
  18. sempy_labs/_gateways.py +103 -99
  19. sempy_labs/_generate_semantic_model.py +22 -30
  20. sempy_labs/_git.py +46 -66
  21. sempy_labs/_graphQL.py +95 -0
  22. sempy_labs/_helper_functions.py +227 -36
  23. sempy_labs/_job_scheduler.py +47 -59
  24. sempy_labs/_kql_databases.py +27 -34
  25. sempy_labs/_kql_querysets.py +23 -30
  26. sempy_labs/_list_functions.py +264 -167
  27. sempy_labs/_managed_private_endpoints.py +52 -47
  28. sempy_labs/_mirrored_databases.py +110 -134
  29. sempy_labs/_mirrored_warehouses.py +13 -13
  30. sempy_labs/_ml_experiments.py +36 -36
  31. sempy_labs/_ml_models.py +37 -38
  32. sempy_labs/_model_bpa.py +2 -2
  33. sempy_labs/_model_bpa_rules.py +8 -6
  34. sempy_labs/_model_dependencies.py +2 -0
  35. sempy_labs/_notebooks.py +28 -29
  36. sempy_labs/_one_lake_integration.py +2 -0
  37. sempy_labs/_query_scale_out.py +63 -81
  38. sempy_labs/_refresh_semantic_model.py +12 -14
  39. sempy_labs/_spark.py +54 -79
  40. sempy_labs/_sql.py +7 -11
  41. sempy_labs/_translations.py +2 -2
  42. sempy_labs/_vertipaq.py +11 -6
  43. sempy_labs/_warehouses.py +30 -33
  44. sempy_labs/_workloads.py +15 -20
  45. sempy_labs/_workspace_identity.py +13 -17
  46. sempy_labs/_workspaces.py +49 -48
  47. sempy_labs/admin/__init__.py +2 -0
  48. sempy_labs/admin/_basic_functions.py +244 -281
  49. sempy_labs/admin/_domains.py +186 -103
  50. sempy_labs/admin/_external_data_share.py +26 -31
  51. sempy_labs/admin/_git.py +17 -22
  52. sempy_labs/admin/_items.py +34 -48
  53. sempy_labs/admin/_scanner.py +61 -49
  54. sempy_labs/directlake/_directlake_schema_compare.py +2 -0
  55. sempy_labs/directlake/_dl_helper.py +10 -11
  56. sempy_labs/directlake/_generate_shared_expression.py +4 -5
  57. sempy_labs/directlake/_get_directlake_lakehouse.py +1 -0
  58. sempy_labs/directlake/_list_directlake_model_calc_tables.py +1 -0
  59. sempy_labs/directlake/_show_unsupported_directlake_objects.py +2 -0
  60. sempy_labs/directlake/_warm_cache.py +2 -0
  61. sempy_labs/graph/__init__.py +33 -0
  62. sempy_labs/graph/_groups.py +402 -0
  63. sempy_labs/graph/_teams.py +113 -0
  64. sempy_labs/graph/_users.py +191 -0
  65. sempy_labs/lakehouse/__init__.py +4 -0
  66. sempy_labs/lakehouse/_get_lakehouse_columns.py +12 -12
  67. sempy_labs/lakehouse/_get_lakehouse_tables.py +16 -22
  68. sempy_labs/lakehouse/_lakehouse.py +104 -7
  69. sempy_labs/lakehouse/_shortcuts.py +42 -20
  70. sempy_labs/migration/__init__.py +4 -0
  71. sempy_labs/migration/_direct_lake_to_import.py +66 -0
  72. sempy_labs/migration/_migrate_calctables_to_lakehouse.py +3 -2
  73. sempy_labs/migration/_migrate_calctables_to_semantic_model.py +1 -0
  74. sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +1 -0
  75. sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +2 -0
  76. sempy_labs/migration/_refresh_calc_tables.py +2 -2
  77. sempy_labs/report/_download_report.py +8 -13
  78. sempy_labs/report/_generate_report.py +49 -46
  79. sempy_labs/report/_paginated.py +20 -26
  80. sempy_labs/report/_report_functions.py +52 -47
  81. sempy_labs/report/_report_list_functions.py +2 -0
  82. sempy_labs/report/_report_rebind.py +6 -10
  83. sempy_labs/report/_reportwrapper.py +187 -220
  84. sempy_labs/tom/_model.py +12 -6
  85. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.3.dist-info}/LICENSE +0 -0
  86. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.3.dist-info}/WHEEL +0 -0
  87. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.3.dist-info}/top_level.txt +0 -0
sempy_labs/_git.py CHANGED
@@ -1,12 +1,10 @@
1
- import sempy.fabric as fabric
2
1
  import pandas as pd
3
2
  import sempy_labs._icons as icons
4
3
  from typing import Optional, List
5
4
  from sempy_labs._helper_functions import (
6
5
  resolve_workspace_name_and_id,
7
- lro,
6
+ _base_api,
8
7
  )
9
- from sempy.fabric.exceptions import FabricHTTPException
10
8
  from uuid import UUID
11
9
 
12
10
 
@@ -43,7 +41,7 @@ def connect_workspace_to_azure_dev_ops(
43
41
 
44
42
  (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
45
43
 
46
- request_body = {
44
+ payload = {
47
45
  "gitProviderDetails": {
48
46
  "organizationName": organization_name,
49
47
  "projectName": project_name,
@@ -54,12 +52,11 @@ def connect_workspace_to_azure_dev_ops(
54
52
  }
55
53
  }
56
54
 
57
- client = fabric.FabricRestClient()
58
- response = client.post(
59
- f"/v1/workspaces/{workspace_id}/git/connect", json=request_body
55
+ _base_api(
56
+ request=f"/v1/workspaces/{workspace_id}/git/connect",
57
+ payload=payload,
58
+ method="post",
60
59
  )
61
- if response.status_code != 200:
62
- raise FabricHTTPException(response)
63
60
 
64
61
  print(
65
62
  f"{icons.green_dot} The '{workspace_name}' workspace has been connected to the '{project_name}' Git project in Azure DevOps within the '{repository_name}' repository."
@@ -102,7 +99,7 @@ def connect_workspace_to_github(
102
99
 
103
100
  (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
104
101
 
105
- request_body = {
102
+ payload = {
106
103
  "gitProviderDetails": {
107
104
  "ownerName": owner_name,
108
105
  "gitProviderType": "GitHub",
@@ -116,12 +113,11 @@ def connect_workspace_to_github(
116
113
  },
117
114
  }
118
115
 
119
- client = fabric.FabricRestClient()
120
- response = client.post(
121
- f"/v1/workspaces/{workspace_id}/git/connect", json=request_body
116
+ _base_api(
117
+ request=f"/v1/workspaces/{workspace_id}/git/connect",
118
+ payload=payload,
119
+ method="post",
122
120
  )
123
- if response.status_code != 200:
124
- raise FabricHTTPException(response)
125
121
 
126
122
  print(
127
123
  f"{icons.green_dot} The '{workspace_name}' workspace has been connected to the '{repository_name}' GitHub repository."
@@ -144,10 +140,7 @@ def disconnect_workspace_from_git(workspace: Optional[str | UUID] = None):
144
140
 
145
141
  (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
146
142
 
147
- client = fabric.FabricRestClient()
148
- response = client.post(f"/v1/workspaces/{workspace_id}/git/disconnect")
149
- if response.status_code != 200:
150
- raise FabricHTTPException(response)
143
+ _base_api(request=f"/v1/workspaces/{workspace_id}/git/disconnect", method="post")
151
144
 
152
145
  print(
153
146
  f"{icons.green_dot} The '{workspace_name}' workspace has been disconnected from Git."
@@ -189,13 +182,11 @@ def get_git_status(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
189
182
  ]
190
183
  )
191
184
 
192
- client = fabric.FabricRestClient()
193
- response = client.get(f"/v1/workspaces/{workspace_id}/git/status")
194
-
195
- if response.status_code not in [200, 202]:
196
- raise FabricHTTPException(response)
197
-
198
- result = lro(client, response).json()
185
+ result = _base_api(
186
+ request=f"/v1/workspaces/{workspace_id}/git/status",
187
+ lro_return_json=True,
188
+ status_codes=None,
189
+ )
199
190
 
200
191
  for changes in result.get("changes", []):
201
192
  item_metadata = changes.get("itemMetadata", {})
@@ -252,11 +243,7 @@ def get_git_connection(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
252
243
  ]
253
244
  )
254
245
 
255
- client = fabric.FabricRestClient()
256
- response = client.get(f"/v1/workspaces/{workspace_id}/git/connection")
257
-
258
- if response.status_code != 200:
259
- raise FabricHTTPException(response)
246
+ response = _base_api(request=f"/v1/workspaces/{workspace_id}/git/connection")
260
247
 
261
248
  r = response.json()
262
249
  provider_details = r.get("gitProviderDetails", {})
@@ -298,19 +285,18 @@ def initialize_git_connection(workspace: Optional[str | UUID] = None) -> str:
298
285
 
299
286
  (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
300
287
 
301
- client = fabric.FabricRestClient()
302
- response = client.post(f"/v1/workspaces/{workspace_id}/git/initializeConnection")
303
-
304
- if response.status_code not in [200, 202]:
305
- raise FabricHTTPException(response)
306
-
307
- lro(client, response)
288
+ response_json = _base_api(
289
+ request=f"/v1/workspaces/{workspace_id}/git/initializeConnection",
290
+ method="post",
291
+ lro_return_json=True,
292
+ status_codes=None,
293
+ )
308
294
 
309
295
  print(
310
296
  f"{icons.green_dot} The '{workspace_name}' workspace git connection has been initialized."
311
297
  )
312
298
 
313
- return response.json().get("remoteCommitHash")
299
+ return response_json.get("remoteCommitHash")
314
300
 
315
301
 
316
302
  def commit_to_git(
@@ -350,26 +336,23 @@ def commit_to_git(
350
336
  if isinstance(item_ids, str):
351
337
  item_ids = [item_ids]
352
338
 
353
- request_body = {
339
+ payload = {
354
340
  "mode": commit_mode,
355
341
  "workspaceHead": workspace_head,
356
342
  "comment": comment,
357
343
  }
358
344
 
359
345
  if item_ids is not None:
360
- request_body["items"] = [{"objectId": item_id} for item_id in item_ids]
361
-
362
- client = fabric.FabricRestClient()
363
- response = client.post(
364
- f"/v1/workspaces/{workspace_id}/git/commitToGit",
365
- json=request_body,
346
+ payload["items"] = [{"objectId": item_id} for item_id in item_ids]
347
+
348
+ _base_api(
349
+ request=f"/v1/workspaces/{workspace_id}/git/commitToGit",
350
+ method="post",
351
+ payload=payload,
352
+ lro_return_status_code=True,
353
+ status_codes=None,
366
354
  )
367
355
 
368
- if response.status_code not in [200, 202]:
369
- raise FabricHTTPException(response)
370
-
371
- lro(client=client, response=response, return_status_code=True)
372
-
373
356
  if commit_mode == "All":
374
357
  print(
375
358
  f"{icons.green_dot} All items within the '{workspace_name}' workspace have been committed to Git."
@@ -426,29 +409,26 @@ def update_from_git(
426
409
  f"{icons.red_dot} Invalid conflict resolution policy. Valid options: {conflict_resolution_policies}."
427
410
  )
428
411
 
429
- request_body = {}
430
- request_body["remoteCommitHash"] = remote_commit_hash
431
- request_body["conflictResolution"] = {
412
+ payload = {}
413
+ payload["remoteCommitHash"] = remote_commit_hash
414
+ payload["conflictResolution"] = {
432
415
  "conflictResolutionType": "Workspace",
433
416
  "conflictResolutionPolicy": conflict_resolution_policy,
434
417
  }
435
418
 
436
419
  if workspace_head is not None:
437
- request_body["workspaceHead"] = workspace_head
420
+ payload["workspaceHead"] = workspace_head
438
421
  if allow_override is not None:
439
- request_body["options"] = {"allowOverrideItems": allow_override}
440
-
441
- client = fabric.FabricRestClient()
442
- response = client.post(
443
- f"/v1/workspaces/{workspace_id}/git/updateFromGit",
444
- json=request_body,
422
+ payload["options"] = {"allowOverrideItems": allow_override}
423
+
424
+ _base_api(
425
+ request=f"/v1/workspaces/{workspace_id}/git/updateFromGit",
426
+ method="post",
427
+ payload=payload,
428
+ lro_return_status_code=True,
429
+ status_codes=None,
445
430
  )
446
431
 
447
- if response.status_code not in [200, 202]:
448
- raise FabricHTTPException(response)
449
-
450
- lro(client, response, return_status_code=True)
451
-
452
432
  print(
453
433
  f"{icons.green_dot} The '{workspace_name}' workspace has been updated with commits pushed to the connected branch."
454
434
  )
sempy_labs/_graphQL.py ADDED
@@ -0,0 +1,95 @@
1
+ import pandas as pd
2
+ from uuid import UUID
3
+ from typing import Optional
4
+ from sempy_labs._helper_functions import (
5
+ _base_api,
6
+ _create_dataframe,
7
+ resolve_workspace_name_and_id,
8
+ _print_success,
9
+ )
10
+
11
+
12
+ def list_graphql_apis(workspace: Optional[str | UUID]) -> pd.DataFrame:
13
+ """
14
+ Shows the Graph QL APIs within a workspace.
15
+
16
+ This is a wrapper function for the following API: `Items - List GraphQLApis <https://learn.microsoft.com/rest/api/fabric/graphqlapi/items/list-graphqlapi-s>`_.
17
+
18
+ Parameters
19
+ ----------
20
+ workspace : str | uuid.UUID, default=None
21
+ The Fabric workspace name or ID.
22
+ Defaults to None which resolves to the workspace of the attached lakehouse
23
+ or if no lakehouse attached, resolves to the workspace of the notebook.
24
+
25
+ Returns
26
+ -------
27
+ pandas.DataFrame
28
+ A pandas dataframe showing the GraphQL APIs within a workspace.
29
+ """
30
+
31
+ columns = {
32
+ "GraphQL API Name": "string",
33
+ "GraphQL API Id": "string",
34
+ "Description": "string",
35
+ }
36
+ df = _create_dataframe(columns=columns)
37
+
38
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
39
+
40
+ responses = _base_api(
41
+ request=f"/v1/workspaces/{workspace_id}/GraphQLApis", uses_pagination=True
42
+ )
43
+
44
+ for r in responses:
45
+ for v in r.get("value", []):
46
+ new_data = {
47
+ "GraphQL API Name": v.get("displayName"),
48
+ "GraphQL API Id": v.get("id"),
49
+ "Description": v.get("description"),
50
+ }
51
+ df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
52
+
53
+ return df
54
+
55
+
56
+ def create_graphql_api(
57
+ name: str, description: Optional[str] = None, workspace: Optional[str | UUID] = None
58
+ ):
59
+ """
60
+ Creates a GraphQL API.
61
+
62
+ This is a wrapper function for the following API: `Items - Create GraphQLApi <https://learn.microsoft.com/rest/api/fabric/graphqlapi/items/create-graphqlapi>`_.
63
+
64
+ Parameters
65
+ ----------
66
+ name: str
67
+ Name of the GraphQL API.
68
+ description : str, default=None
69
+ A description of the GraphQL API.
70
+ workspace : str | uuid.UUID, default=None
71
+ The Fabric workspace name or ID.
72
+ Defaults to None which resolves to the workspace of the attached lakehouse
73
+ or if no lakehouse attached, resolves to the workspace of the notebook.
74
+ """
75
+
76
+ (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
77
+
78
+ payload = {"displayName": name}
79
+
80
+ if description:
81
+ payload["description"] = description
82
+
83
+ _base_api(
84
+ request=f"/v1/workspaces/{workspace_id}/GraphQLApis",
85
+ method="post",
86
+ status_codes=[201, 202],
87
+ payload=payload,
88
+ lro_return_status_code=True,
89
+ )
90
+ _print_success(
91
+ item_name=name,
92
+ item_type="GraphQL API",
93
+ workspace_name=workspace_name,
94
+ action="created",
95
+ )