semantic-link-labs 0.9.1__py3-none-any.whl → 0.9.2__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 (82) hide show
  1. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.2.dist-info}/METADATA +66 -8
  2. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.2.dist-info}/RECORD +82 -75
  3. sempy_labs/__init__.py +14 -12
  4. sempy_labs/_capacities.py +120 -142
  5. sempy_labs/_capacity_migration.py +61 -94
  6. sempy_labs/_clear_cache.py +9 -8
  7. sempy_labs/_connections.py +72 -105
  8. sempy_labs/_data_pipelines.py +47 -49
  9. sempy_labs/_dataflows.py +45 -51
  10. sempy_labs/_dax.py +228 -6
  11. sempy_labs/_delta_analyzer.py +303 -0
  12. sempy_labs/_deployment_pipelines.py +72 -66
  13. sempy_labs/_environments.py +39 -36
  14. sempy_labs/_eventhouses.py +35 -35
  15. sempy_labs/_eventstreams.py +38 -39
  16. sempy_labs/_external_data_shares.py +29 -42
  17. sempy_labs/_gateways.py +57 -101
  18. sempy_labs/_generate_semantic_model.py +22 -30
  19. sempy_labs/_git.py +46 -66
  20. sempy_labs/_graphQL.py +95 -0
  21. sempy_labs/_helper_functions.py +175 -30
  22. sempy_labs/_job_scheduler.py +47 -59
  23. sempy_labs/_kql_databases.py +27 -34
  24. sempy_labs/_kql_querysets.py +23 -30
  25. sempy_labs/_list_functions.py +262 -164
  26. sempy_labs/_managed_private_endpoints.py +52 -47
  27. sempy_labs/_mirrored_databases.py +110 -134
  28. sempy_labs/_mirrored_warehouses.py +13 -13
  29. sempy_labs/_ml_experiments.py +36 -36
  30. sempy_labs/_ml_models.py +37 -38
  31. sempy_labs/_model_dependencies.py +2 -0
  32. sempy_labs/_notebooks.py +28 -29
  33. sempy_labs/_one_lake_integration.py +2 -0
  34. sempy_labs/_query_scale_out.py +63 -81
  35. sempy_labs/_refresh_semantic_model.py +12 -14
  36. sempy_labs/_spark.py +54 -79
  37. sempy_labs/_sql.py +7 -11
  38. sempy_labs/_vertipaq.py +8 -3
  39. sempy_labs/_warehouses.py +30 -33
  40. sempy_labs/_workloads.py +15 -20
  41. sempy_labs/_workspace_identity.py +13 -17
  42. sempy_labs/_workspaces.py +49 -48
  43. sempy_labs/admin/__init__.py +2 -0
  44. sempy_labs/admin/_basic_functions.py +244 -281
  45. sempy_labs/admin/_domains.py +188 -103
  46. sempy_labs/admin/_external_data_share.py +26 -31
  47. sempy_labs/admin/_git.py +17 -22
  48. sempy_labs/admin/_items.py +34 -48
  49. sempy_labs/admin/_scanner.py +20 -13
  50. sempy_labs/directlake/_directlake_schema_compare.py +2 -0
  51. sempy_labs/directlake/_dl_helper.py +10 -11
  52. sempy_labs/directlake/_generate_shared_expression.py +4 -5
  53. sempy_labs/directlake/_get_directlake_lakehouse.py +1 -0
  54. sempy_labs/directlake/_list_directlake_model_calc_tables.py +1 -0
  55. sempy_labs/directlake/_show_unsupported_directlake_objects.py +2 -0
  56. sempy_labs/directlake/_warm_cache.py +2 -0
  57. sempy_labs/graph/__init__.py +33 -0
  58. sempy_labs/graph/_groups.py +402 -0
  59. sempy_labs/graph/_teams.py +113 -0
  60. sempy_labs/graph/_users.py +191 -0
  61. sempy_labs/lakehouse/__init__.py +4 -0
  62. sempy_labs/lakehouse/_get_lakehouse_columns.py +10 -10
  63. sempy_labs/lakehouse/_get_lakehouse_tables.py +14 -20
  64. sempy_labs/lakehouse/_lakehouse.py +101 -4
  65. sempy_labs/lakehouse/_shortcuts.py +42 -20
  66. sempy_labs/migration/__init__.py +4 -0
  67. sempy_labs/migration/_direct_lake_to_import.py +66 -0
  68. sempy_labs/migration/_migrate_calctables_to_lakehouse.py +1 -0
  69. sempy_labs/migration/_migrate_calctables_to_semantic_model.py +1 -0
  70. sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +1 -0
  71. sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +2 -0
  72. sempy_labs/report/_download_report.py +8 -13
  73. sempy_labs/report/_generate_report.py +49 -46
  74. sempy_labs/report/_paginated.py +20 -26
  75. sempy_labs/report/_report_functions.py +50 -45
  76. sempy_labs/report/_report_list_functions.py +2 -0
  77. sempy_labs/report/_report_rebind.py +6 -10
  78. sempy_labs/report/_reportwrapper.py +187 -220
  79. sempy_labs/tom/_model.py +8 -5
  80. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.2.dist-info}/LICENSE +0 -0
  81. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.2.dist-info}/WHEEL +0 -0
  82. {semantic_link_labs-0.9.1.dist-info → semantic_link_labs-0.9.2.dist-info}/top_level.txt +0 -0
@@ -12,33 +12,34 @@ from sempy_labs.admin._basic_functions import (
12
12
  from sempy_labs._helper_functions import (
13
13
  resolve_capacity_id,
14
14
  convert_to_alphanumeric_lowercase,
15
+ _base_api,
15
16
  )
16
17
  from sempy_labs._capacities import create_fabric_capacity
17
18
 
18
19
 
19
- def migrate_settings(source_capacity: str, target_capacity: str):
20
+ def _migrate_settings(source_capacity: str, target_capacity: str):
20
21
 
21
- migrate_capacity_settings(
22
+ _migrate_capacity_settings(
22
23
  source_capacity=source_capacity,
23
24
  target_capacity=target_capacity,
24
25
  )
25
- migrate_access_settings(
26
+ _migrate_access_settings(
26
27
  source_capacity=source_capacity,
27
28
  target_capacity=target_capacity,
28
29
  )
29
- migrate_notification_settings(
30
+ _migrate_notification_settings(
30
31
  source_capacity=source_capacity,
31
32
  target_capacity=target_capacity,
32
33
  )
33
- migrate_spark_settings(
34
+ _migrate_spark_settings(
34
35
  source_capacity=source_capacity,
35
36
  target_capacity=target_capacity,
36
37
  )
37
- migrate_delegated_tenant_settings(
38
+ _migrate_delegated_tenant_settings(
38
39
  source_capacity=source_capacity,
39
40
  target_capacity=target_capacity,
40
41
  )
41
- migrate_disaster_recovery_settings(
42
+ _migrate_disaster_recovery_settings(
42
43
  source_capacity=source_capacity,
43
44
  target_capacity=target_capacity,
44
45
  )
@@ -233,11 +234,11 @@ def migrate_capacities(
233
234
  )
234
235
 
235
236
  # Migrate settings to new capacity
236
- # migrate_settings(source_capacity=cap_name, target_capacity=tgt_capacity)
237
+ # _migrate_settings(source_capacity=cap_name, target_capacity=tgt_capacity)
237
238
 
238
239
 
239
240
  @log
240
- def migrate_capacity_settings(source_capacity: str, target_capacity: str):
241
+ def _migrate_capacity_settings(source_capacity: str, target_capacity: str):
241
242
  """
242
243
  This function migrates a capacity's settings to another capacity.
243
244
 
@@ -265,13 +266,9 @@ def migrate_capacity_settings(source_capacity: str, target_capacity: str):
265
266
 
266
267
  workloads_params = "capacityCustomParameters?workloadIds=ADM&workloadIds=CDSA&workloadIds=DMS&workloadIds=RsRdlEngine&workloadIds=ScreenshotEngine&workloadIds=AS&workloadIds=QES&workloadIds=DMR&workloadIds=ESGLake&workloadIds=NLS&workloadIds=lake&workloadIds=TIPS&workloadIds=Kusto&workloadIds=Lakehouse&workloadIds=SparkCore&workloadIds=DI&workloadIds=Notebook&workloadIds=ML&workloadIds=ES&workloadIds=Reflex&workloadIds=Must&workloadIds=dmh&workloadIds=PowerBI&workloadIds=HLS"
267
268
 
268
- client = fabric.PowerBIRestClient()
269
- response_get_source = client.get(
270
- f"capacities/{source_capacity_id}/{workloads_params}"
269
+ response_get_source = _base_api(
270
+ request=f"capacities/{source_capacity_id}/{workloads_params}"
271
271
  )
272
- if response_get_source.status_code != 200:
273
- raise FabricHTTPException(response_get_source)
274
-
275
272
  response_source_json = response_get_source.json().get(
276
273
  "capacityCustomParameters", {}
277
274
  )
@@ -317,12 +314,12 @@ def migrate_capacity_settings(source_capacity: str, target_capacity: str):
317
314
  "workloadCustomParameters"
318
315
  ][setting_name] = setting_value
319
316
 
320
- response_put = client.put(
321
- f"capacities/{target_capacity_id}/{workloads_params}",
322
- json=settings_json,
317
+ _base_api(
318
+ request=f"capacities/{target_capacity_id}/{workloads_params}",
319
+ method="put",
320
+ payload=settings_json,
321
+ status_codes=204,
323
322
  )
324
- if response_put.status_code != 204:
325
- raise FabricHTTPException(response_put)
326
323
 
327
324
  print(
328
325
  f"{icons.green_dot} The capacity settings have been migrated from the '{source_capacity}' capacity to the '{target_capacity}' capacity."
@@ -330,7 +327,7 @@ def migrate_capacity_settings(source_capacity: str, target_capacity: str):
330
327
 
331
328
 
332
329
  @log
333
- def migrate_disaster_recovery_settings(source_capacity: str, target_capacity: str):
330
+ def _migrate_disaster_recovery_settings(source_capacity: str, target_capacity: str):
334
331
  """
335
332
  This function migrates a capacity's disaster recovery settings to another capacity.
336
333
 
@@ -356,28 +353,25 @@ def migrate_disaster_recovery_settings(source_capacity: str, target_capacity: st
356
353
  )
357
354
  target_capacity_id = dfC_filt["Capacity Id"].iloc[0].upper()
358
355
 
359
- client = fabric.PowerBIRestClient()
360
- response_get_source = client.get(f"capacities/{source_capacity_id}/config")
361
- if response_get_source.status_code != 200:
362
- raise FabricHTTPException(response_get_source)
356
+ response_get_source = _base_api(request=f"capacities/{source_capacity_id}/config")
363
357
 
364
- request_body = {}
358
+ payload = {}
365
359
  value = response_get_source.json()["bcdr"]["config"]
366
- request_body["config"] = value
360
+ payload["config"] = value
367
361
 
368
- response_put = client.put(
369
- f"capacities/{target_capacity_id}/fabricbcdr", json=request_body
362
+ _base_api(
363
+ request=f"capacities/{target_capacity_id}/fabricbcdr",
364
+ payload=payload,
365
+ status_codes=202,
366
+ method="put",
370
367
  )
371
-
372
- if response_put.status_code != 202:
373
- raise FabricHTTPException(response_put)
374
368
  print(
375
369
  f"{icons.green_dot} The disaster recovery settings have been migrated from the '{source_capacity}' capacity to the '{target_capacity}' capacity."
376
370
  )
377
371
 
378
372
 
379
373
  @log
380
- def migrate_access_settings(source_capacity: str, target_capacity: str):
374
+ def _migrate_access_settings(source_capacity: str, target_capacity: str):
381
375
  """
382
376
  This function migrates the access settings from a source capacity to a target capacity.
383
377
 
@@ -391,31 +385,28 @@ def migrate_access_settings(source_capacity: str, target_capacity: str):
391
385
 
392
386
  dfC = list_capacities()
393
387
  dfC_filt = dfC[dfC["Capacity Name"] == source_capacity]
394
- if len(dfC_filt) == 0:
388
+ if dfC_filt.empty:
395
389
  raise ValueError(
396
390
  f"{icons.red_dot} The '{source_capacity}' capacity does not exist."
397
391
  )
398
392
  source_capacity_id = dfC_filt["Capacity Id"].iloc[0].upper()
399
393
  dfC_filt = dfC[dfC["Capacity Name"] == target_capacity]
400
- if len(dfC_filt) == 0:
394
+ if dfC_filt.empty:
401
395
  raise ValueError(
402
396
  f"{icons.red_dot} The '{target_capacity}' capacity does not exist."
403
397
  )
404
398
  target_capacity_id = dfC_filt["Capacity Id"].iloc[0].upper()
405
399
 
406
- client = fabric.PowerBIRestClient()
407
- response_get_source = client.get(f"capacities/{source_capacity_id}")
408
- if response_get_source.status_code != 200:
409
- raise FabricHTTPException(response_get_source)
400
+ response_get_source = _base_api(request=f"capacities/{source_capacity_id}")
410
401
 
411
- access_settings = response_get_source.json().get("access", {})
402
+ payload = response_get_source.json().get("access", {})
412
403
 
413
- response_put = client.put(
414
- f"capacities/{target_capacity_id}/access",
415
- json=access_settings,
404
+ _base_api(
405
+ request=f"capacities/{target_capacity_id}/access",
406
+ method="put",
407
+ payload=payload,
408
+ status_codes=204,
416
409
  )
417
- if response_put.status_code != 204:
418
- raise FabricHTTPException(response_put)
419
410
 
420
411
  print(
421
412
  f"{icons.green_dot} The access settings have been migrated from the '{source_capacity}' capacity to the '{target_capacity}' capacity."
@@ -423,7 +414,7 @@ def migrate_access_settings(source_capacity: str, target_capacity: str):
423
414
 
424
415
 
425
416
  @log
426
- def migrate_notification_settings(source_capacity: str, target_capacity: str):
417
+ def _migrate_notification_settings(source_capacity: str, target_capacity: str):
427
418
  """
428
419
  This function migrates the notification settings from a source capacity to a target capacity.
429
420
 
@@ -437,33 +428,28 @@ def migrate_notification_settings(source_capacity: str, target_capacity: str):
437
428
 
438
429
  dfC = list_capacities()
439
430
  dfC_filt = dfC[dfC["Capacity Name"] == source_capacity]
440
- if len(dfC_filt) == 0:
431
+ if dfC_filt.empty:
441
432
  raise ValueError(
442
433
  f"{icons.red_dot} The '{source_capacity}' capacity does not exist."
443
434
  )
444
435
  source_capacity_id = dfC_filt["Capacity Id"].iloc[0].upper()
445
436
  dfC_filt = dfC[dfC["Capacity Name"] == target_capacity]
446
- if len(dfC_filt) == 0:
437
+ if dfC_filt.empty:
447
438
  raise ValueError(
448
439
  f"{icons.red_dot} The '{target_capacity}' capacity does not exist."
449
440
  )
450
441
  target_capacity_id = dfC_filt["Capacity Id"].iloc[0].upper()
451
442
 
452
- client = fabric.PowerBIRestClient()
453
- response_get_source = client.get(f"capacities/{source_capacity_id}")
454
- if response_get_source.status_code != 200:
455
- raise FabricHTTPException(response_get_source)
443
+ response_get_source = _base_api(request=f"capacities/{source_capacity_id}")
456
444
 
457
- notification_settings = response_get_source.json().get(
458
- "capacityNotificationSettings", {}
459
- )
445
+ payload = response_get_source.json().get("capacityNotificationSettings", {})
460
446
 
461
- response_put = client.put(
462
- f"capacities/{target_capacity_id}/notificationSettings",
463
- json=notification_settings,
447
+ _base_api(
448
+ request=f"capacities/{target_capacity_id}/notificationSettings",
449
+ method="put",
450
+ payload=payload,
451
+ status_codes=204,
464
452
  )
465
- if response_put.status_code != 204:
466
- raise FabricHTTPException(response_put)
467
453
 
468
454
  print(
469
455
  f"{icons.green_dot} The notification settings have been migrated from the '{source_capacity}' capacity to the '{target_capacity}' capacity."
@@ -471,7 +457,7 @@ def migrate_notification_settings(source_capacity: str, target_capacity: str):
471
457
 
472
458
 
473
459
  @log
474
- def migrate_delegated_tenant_settings(source_capacity: str, target_capacity: str):
460
+ def _migrate_delegated_tenant_settings(source_capacity: str, target_capacity: str):
475
461
  """
476
462
  This function migrates the delegated tenant settings from a source capacity to a target capacity.
477
463
 
@@ -486,24 +472,20 @@ def migrate_delegated_tenant_settings(source_capacity: str, target_capacity: str
486
472
  dfC = list_capacities()
487
473
 
488
474
  dfC_filt = dfC[dfC["Capacity Name"] == source_capacity]
489
- if len(dfC_filt) == 0:
475
+ if dfC_filt.empty:
490
476
  raise ValueError(
491
477
  f"{icons.red_dot} The '{source_capacity}' capacity does not exist."
492
478
  )
493
479
  source_capacity_id = dfC_filt["Capacity Id"].iloc[0].upper()
494
480
 
495
481
  dfC_filt = dfC[dfC["Capacity Name"] == target_capacity]
496
- if len(dfC_filt) == 0:
482
+ if dfC_filt.empty:
497
483
  raise ValueError(
498
484
  f"{icons.red_dot} The '{target_capacity}' capacity does not exist."
499
485
  )
500
486
  target_capacity_id = dfC_filt["Capacity Id"].iloc[0].upper()
501
487
 
502
- client = fabric.FabricRestClient()
503
- response_get = client.get("v1/admin/capacities/delegatedTenantSettingOverrides")
504
-
505
- if response_get.status_code != 200:
506
- raise FabricHTTPException(response_get)
488
+ response_get = _base_api("v1/admin/capacities/delegatedTenantSettingOverrides")
507
489
 
508
490
  response_json = response_get.json().get("Overrides", [])
509
491
 
@@ -536,13 +518,11 @@ def migrate_delegated_tenant_settings(source_capacity: str, target_capacity: str
536
518
 
537
519
  payload = {"featureSwitches": [feature_switch], "properties": []}
538
520
 
539
- client = fabric.PowerBIRestClient()
540
- response_put = client.put(
541
- f"metadata/tenantsettings/selfserve?capacityObjectId={target_capacity_id}",
542
- json=payload,
521
+ _base_api(
522
+ request=f"metadata/tenantsettings/selfserve?capacityObjectId={target_capacity_id}",
523
+ method="put",
524
+ payload=payload,
543
525
  )
544
- if response_put.status_code != 200:
545
- raise FabricHTTPException(response_put)
546
526
 
547
527
  print(
548
528
  f"{icons.green_dot} The delegated tenant settings for the '{setting_name}' feature switch of the '{source_capacity}' capacity have been migrated to the '{target_capacity}' capacity."
@@ -550,7 +530,7 @@ def migrate_delegated_tenant_settings(source_capacity: str, target_capacity: str
550
530
 
551
531
 
552
532
  @log
553
- def migrate_spark_settings(source_capacity: str, target_capacity: str):
533
+ def _migrate_spark_settings(source_capacity: str, target_capacity: str):
554
534
  """
555
535
  This function migrates a capacity's spark settings to another capacity.
556
536
 
@@ -566,21 +546,14 @@ def migrate_spark_settings(source_capacity: str, target_capacity: str):
566
546
 
567
547
  source_capacity_id = resolve_capacity_id(capacity_name=source_capacity)
568
548
  target_capacity_id = resolve_capacity_id(capacity_name=target_capacity)
569
- client = fabric.PowerBIRestClient()
570
549
 
571
550
  # Get source capacity server dns
572
- response = client.get(f"metadata/capacityInformation/{source_capacity_id}")
573
- if response.status_code != 200:
574
- raise FabricHTTPException(response)
575
-
551
+ response = _base_api(request=f"metadata/capacityInformation/{source_capacity_id}")
576
552
  source_server_dns = response.json().get("capacityDns")
577
553
  source_url = f"{source_server_dns}/webapi/capacities"
578
554
 
579
555
  # Get target capacity server dns
580
- response = client.get(f"metadata/capacityInformation/{target_capacity_id}")
581
- if response.status_code != 200:
582
- raise FabricHTTPException(response)
583
-
556
+ response = _base_api(request=f"metadata/capacityInformation/{target_capacity_id}")
584
557
  target_server_dns = response.json().get("capacityDns")
585
558
  target_url = f"{target_server_dns}/webapi/capacities"
586
559
 
@@ -590,17 +563,11 @@ def migrate_spark_settings(source_capacity: str, target_capacity: str):
590
563
  put_url = f"{target_url}/{target_capacity_id}/{end_url}/content"
591
564
 
592
565
  # Get source capacity spark settings
593
- response = client.get(get_url)
594
- if response.status_code != 200:
595
- raise FabricHTTPException(response)
596
-
566
+ response = _base_api(request=get_url)
597
567
  payload = response.json().get("content")
598
568
 
599
569
  # Update target capacity spark settings
600
- response_put = client.put(put_url, json=payload)
601
-
602
- if response_put.status_code != 200:
603
- raise FabricHTTPException(response_put)
570
+ _base_api(request=put_url, method="put", payload=payload)
604
571
  print(
605
572
  f"{icons.green_dot} The spark settings have been migrated from the '{source_capacity}' capacity to the '{target_capacity}' capacity."
606
573
  )
@@ -643,7 +610,7 @@ def migrate_fabric_trial_capacity(
643
610
  dfC = list_capacities()
644
611
  dfC_filt = dfC[dfC["Capacity Name"] == source_capacity]
645
612
 
646
- if len(dfC_filt) == 0:
613
+ if dfC_filt.empty:
647
614
  raise ValueError(
648
615
  f"{icons.red_dot} The {source_capacity}' capacity does not exist."
649
616
  )
@@ -688,7 +655,7 @@ def migrate_fabric_trial_capacity(
688
655
  )
689
656
 
690
657
  # This migrates all the capacity settings
691
- # migrate_settings(
658
+ # _migrate_settings(
692
659
  # source_capacity=source_capacity,
693
660
  # target_capacity=target_capacity,
694
661
  # )
@@ -4,12 +4,13 @@ from sempy_labs._helper_functions import (
4
4
  _get_adls_client,
5
5
  resolve_workspace_name_and_id,
6
6
  resolve_dataset_name_and_id,
7
+ _update_dataframe_datatypes,
8
+ _base_api,
7
9
  )
8
10
  from typing import Optional
9
11
  import sempy_labs._icons as icons
10
12
  from sempy._utils._log import log
11
13
  import pandas as pd
12
- from sempy.fabric.exceptions import FabricHTTPException
13
14
  from uuid import UUID
14
15
 
15
16
 
@@ -264,15 +265,11 @@ def list_backups(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
264
265
  A pandas dataframe showing a list of backup files contained within a workspace's ADLS Gen2 storage account.
265
266
  """
266
267
 
267
- client = fabric.PowerBIRestClient()
268
268
  (workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
269
- response = client.get(
270
- f"/v1.0/myorg/resources?resourceType=StorageAccount&folderObjectId={workspace_id}"
269
+ response = _base_api(
270
+ request=f"/v1.0/myorg/resources?resourceType=StorageAccount&folderObjectId={workspace_id}"
271
271
  )
272
272
 
273
- if response.status_code != 200:
274
- raise FabricHTTPException(response)
275
-
276
273
  v = response.json().get("value", [])
277
274
  if not v:
278
275
  raise ValueError(
@@ -334,6 +331,10 @@ def list_storage_account_files(
334
331
 
335
332
  df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
336
333
 
337
- df["File Size"] = df["File Size"].astype(int)
334
+ column_map = {
335
+ "File Size": "int",
336
+ }
337
+
338
+ _update_dataframe_datatypes(dataframe=df, column_map=column_map)
338
339
 
339
340
  return df