semantic-link-labs 0.9.0__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 (83) hide show
  1. {semantic_link_labs-0.9.0.dist-info → semantic_link_labs-0.9.2.dist-info}/METADATA +68 -7
  2. {semantic_link_labs-0.9.0.dist-info → semantic_link_labs-0.9.2.dist-info}/RECORD +83 -76
  3. sempy_labs/__init__.py +14 -12
  4. sempy_labs/_authentication.py +0 -2
  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 +72 -105
  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 +303 -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 +57 -101
  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 +175 -30
  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 +262 -164
  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_dependencies.py +2 -0
  33. sempy_labs/_notebooks.py +28 -29
  34. sempy_labs/_one_lake_integration.py +2 -0
  35. sempy_labs/_query_scale_out.py +63 -81
  36. sempy_labs/_refresh_semantic_model.py +12 -14
  37. sempy_labs/_spark.py +54 -79
  38. sempy_labs/_sql.py +7 -11
  39. sempy_labs/_vertipaq.py +8 -3
  40. sempy_labs/_warehouses.py +30 -33
  41. sempy_labs/_workloads.py +15 -20
  42. sempy_labs/_workspace_identity.py +13 -17
  43. sempy_labs/_workspaces.py +49 -48
  44. sempy_labs/admin/__init__.py +2 -0
  45. sempy_labs/admin/_basic_functions.py +244 -281
  46. sempy_labs/admin/_domains.py +188 -103
  47. sempy_labs/admin/_external_data_share.py +26 -31
  48. sempy_labs/admin/_git.py +17 -22
  49. sempy_labs/admin/_items.py +34 -48
  50. sempy_labs/admin/_scanner.py +20 -13
  51. sempy_labs/directlake/_directlake_schema_compare.py +2 -0
  52. sempy_labs/directlake/_dl_helper.py +10 -11
  53. sempy_labs/directlake/_generate_shared_expression.py +4 -5
  54. sempy_labs/directlake/_get_directlake_lakehouse.py +1 -0
  55. sempy_labs/directlake/_list_directlake_model_calc_tables.py +1 -0
  56. sempy_labs/directlake/_show_unsupported_directlake_objects.py +2 -0
  57. sempy_labs/directlake/_warm_cache.py +2 -0
  58. sempy_labs/graph/__init__.py +33 -0
  59. sempy_labs/graph/_groups.py +402 -0
  60. sempy_labs/graph/_teams.py +113 -0
  61. sempy_labs/graph/_users.py +191 -0
  62. sempy_labs/lakehouse/__init__.py +4 -0
  63. sempy_labs/lakehouse/_get_lakehouse_columns.py +10 -10
  64. sempy_labs/lakehouse/_get_lakehouse_tables.py +14 -20
  65. sempy_labs/lakehouse/_lakehouse.py +101 -4
  66. sempy_labs/lakehouse/_shortcuts.py +42 -20
  67. sempy_labs/migration/__init__.py +4 -0
  68. sempy_labs/migration/_direct_lake_to_import.py +66 -0
  69. sempy_labs/migration/_migrate_calctables_to_lakehouse.py +1 -0
  70. sempy_labs/migration/_migrate_calctables_to_semantic_model.py +1 -0
  71. sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +1 -0
  72. sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +2 -0
  73. sempy_labs/report/_download_report.py +8 -13
  74. sempy_labs/report/_generate_report.py +49 -46
  75. sempy_labs/report/_paginated.py +20 -26
  76. sempy_labs/report/_report_functions.py +50 -45
  77. sempy_labs/report/_report_list_functions.py +2 -0
  78. sempy_labs/report/_report_rebind.py +6 -10
  79. sempy_labs/report/_reportwrapper.py +187 -220
  80. sempy_labs/tom/_model.py +8 -5
  81. {semantic_link_labs-0.9.0.dist-info → semantic_link_labs-0.9.2.dist-info}/LICENSE +0 -0
  82. {semantic_link_labs-0.9.0.dist-info → semantic_link_labs-0.9.2.dist-info}/WHEEL +0 -0
  83. {semantic_link_labs-0.9.0.dist-info → semantic_link_labs-0.9.2.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,3 @@
1
- import sempy.fabric as fabric
2
1
  from sempy_labs._helper_functions import (
3
2
  resolve_report_id,
4
3
  format_dax_object_name,
@@ -6,9 +5,11 @@ from sempy_labs._helper_functions import (
6
5
  _conv_b64,
7
6
  _extract_json,
8
7
  _add_part,
9
- lro,
10
8
  _decode_b64,
11
9
  resolve_workspace_name_and_id,
10
+ _update_dataframe_datatypes,
11
+ _base_api,
12
+ _create_dataframe,
12
13
  )
13
14
  from typing import Optional, List
14
15
  import pandas as pd
@@ -21,6 +22,7 @@ import sempy_labs.report._report_helper as helper
21
22
  from sempy_labs._model_dependencies import get_measure_dependencies
22
23
  from jsonpath_ng.ext import parse
23
24
  import warnings
25
+ import requests
24
26
 
25
27
 
26
28
  class ReportWrapper:
@@ -144,14 +146,14 @@ class ReportWrapper:
144
146
 
145
147
  def update_report(self, request_body: dict):
146
148
 
147
- client = fabric.FabricRestClient()
148
- response = client.post(
149
- f"/v1/workspaces/{self._workspace_id}/reports/{self._report_id}/updateDefinition",
150
- json=request_body,
149
+ _base_api(
150
+ request=f"/v1/workspaces/{self._workspace_id}/reports/{self._report_id}/updateDefinition",
151
+ method="post",
152
+ payload=request_body,
153
+ lro_return_status_code=True,
154
+ status_codes=None,
151
155
  )
152
156
 
153
- lro(client, response, return_status_code=True)
154
-
155
157
  def resolve_page_name(self, page_display_name: str) -> UUID:
156
158
  """
157
159
  Obtains the page name, page display name, and the file path for a given page in a report.
@@ -253,7 +255,13 @@ class ReportWrapper:
253
255
 
254
256
  helper.populate_custom_visual_display_names()
255
257
 
256
- df = pd.DataFrame(columns=["Custom Visual Name", "Custom Visual Display Name"])
258
+ columns = {
259
+ "Custom Visual Name": "str",
260
+ "Custom Visual Display Name": "str",
261
+ "Used in Report": "bool",
262
+ }
263
+
264
+ df = _create_dataframe(columns=columns)
257
265
  rd = self.rdef
258
266
  rd_filt = rd[rd["path"] == "definition/report.json"]
259
267
  rptJson = _extract_json(rd_filt)
@@ -266,8 +274,7 @@ class ReportWrapper:
266
274
  self.list_visuals()["Type"]
267
275
  )
268
276
 
269
- bool_cols = ["Used in Report"]
270
- df[bool_cols] = df[bool_cols].astype(bool)
277
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
271
278
 
272
279
  return df
273
280
 
@@ -289,19 +296,18 @@ class ReportWrapper:
289
296
 
290
297
  rd_filt = self.rdef[self.rdef["path"] == "definition/report.json"]
291
298
 
292
- df = pd.DataFrame(
293
- columns=[
294
- "Filter Name",
295
- "Type",
296
- "Table Name",
297
- "Object Name",
298
- "Object Type",
299
- "Hidden",
300
- "Locked",
301
- "How Created",
302
- "Used",
303
- ]
304
- )
299
+ columns = {
300
+ "Filter Name": "str",
301
+ "Type": "str",
302
+ "Table Name": "str",
303
+ "Object Name": "str",
304
+ "Object Type": "str",
305
+ "Hidden": "bool",
306
+ "Locked": "bool",
307
+ "How Created": "str",
308
+ "Used": "bool",
309
+ }
310
+ df = _create_dataframe(columns=columns)
305
311
 
306
312
  if len(rd_filt) == 1:
307
313
  rpt_json = _extract_json(rd_filt)
@@ -333,8 +339,7 @@ class ReportWrapper:
333
339
  [df, pd.DataFrame(new_data, index=[0])], ignore_index=True
334
340
  )
335
341
 
336
- bool_cols = ["Hidden", "Locked", "Used"]
337
- df[bool_cols] = df[bool_cols].astype(bool)
342
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
338
343
 
339
344
  if extended:
340
345
  df = self._add_extended(dataframe=df)
@@ -357,24 +362,22 @@ class ReportWrapper:
357
362
  A pandas dataframe containing a list of all the page filters used in the report.
358
363
  """
359
364
 
360
- rd = self.rdef
361
- df = pd.DataFrame(
362
- columns=[
363
- "Page Name",
364
- "Page Display Name",
365
- "Filter Name",
366
- "Type",
367
- "Table Name",
368
- "Object Name",
369
- "Object Type",
370
- "Hidden",
371
- "Locked",
372
- "How Created",
373
- "Used",
374
- ]
375
- )
365
+ columns = {
366
+ "Page Name": "str",
367
+ "Page Display Name": "str",
368
+ "Filter Name": "str",
369
+ "Type": "str",
370
+ "Table Name": "str",
371
+ "Object Name": "str",
372
+ "Object Type": "str",
373
+ "Hidden": "bool",
374
+ "Locked": "bool",
375
+ "How Created": "str",
376
+ "Used": "bool",
377
+ }
378
+ df = _create_dataframe(columns=columns)
376
379
 
377
- for _, r in rd.iterrows():
380
+ for _, r in self.rdef.iterrows():
378
381
  path = r["path"]
379
382
  payload = r["payload"]
380
383
  if path.endswith("/page.json"):
@@ -420,14 +423,12 @@ class ReportWrapper:
420
423
  lambda page_name: f"{helper.get_web_url(report=self._report, workspace=self._workspace_id)}/{page_name}"
421
424
  )
422
425
 
423
- bool_cols = ["Hidden", "Locked", "Used"]
424
- df[bool_cols] = df[bool_cols].astype(bool)
426
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
425
427
 
426
428
  if extended:
427
429
  df = self._add_extended(dataframe=df)
428
430
 
429
431
  return df
430
- # return df.style.format({"Page URL": _make_clickable})
431
432
 
432
433
  def list_visual_filters(self, extended: bool = False) -> pd.DataFrame:
433
434
  """
@@ -445,26 +446,25 @@ class ReportWrapper:
445
446
  A pandas dataframe containing a list of all the visual filters used in the report.
446
447
  """
447
448
 
448
- rd = self.rdef
449
- df = pd.DataFrame(
450
- columns=[
451
- "Page Name",
452
- "Page Display Name",
453
- "Visual Name",
454
- "Filter Name",
455
- "Type",
456
- "Table Name",
457
- "Object Name",
458
- "Object Type",
459
- "Hidden",
460
- "Locked",
461
- "How Created",
462
- "Used",
463
- ]
464
- )
449
+ columns = {
450
+ "Page Name": "str",
451
+ "Page Display Name": "str",
452
+ "Visual Name": "str",
453
+ "Filter Name": "str",
454
+ "Type": "str",
455
+ "Table Name": "str",
456
+ "Object Name": "str",
457
+ "Object Type": "str",
458
+ "Hidden": "bool",
459
+ "Locked": "bool",
460
+ "How Created": "str",
461
+ "Used": "bool",
462
+ }
463
+ df = _create_dataframe(columns=columns)
464
+
465
465
  page_mapping, visual_mapping = helper.visual_page_mapping(self)
466
466
 
467
- for _, r in rd.iterrows():
467
+ for _, r in self.rdef.iterrows():
468
468
  path = r["path"]
469
469
  payload = r["payload"]
470
470
  if path.endswith("/visual.json"):
@@ -508,8 +508,7 @@ class ReportWrapper:
508
508
  ignore_index=True,
509
509
  )
510
510
 
511
- bool_cols = ["Hidden", "Locked", "Used"]
512
- df[bool_cols] = df[bool_cols].astype(bool)
511
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
513
512
 
514
513
  if extended:
515
514
  df = self._add_extended(dataframe=df)
@@ -529,18 +528,16 @@ class ReportWrapper:
529
528
  A pandas dataframe containing a list of all modified visual interactions used in the report.
530
529
  """
531
530
 
532
- rd = self.rdef
533
- df = pd.DataFrame(
534
- columns=[
535
- "Page Name",
536
- "Page Display Name",
537
- "Source Visual Name",
538
- "Target Visual Name",
539
- "Type",
540
- ]
541
- )
531
+ columns = {
532
+ "Page Name": "str",
533
+ "Page Display Name": "str",
534
+ "Source Visual Name": "str",
535
+ "Target Visual Name": "str",
536
+ "Type": "str",
537
+ }
538
+ df = _create_dataframe(columns=columns)
542
539
 
543
- for _, r in rd.iterrows():
540
+ for _, r in self.rdef.iterrows():
544
541
  file_path = r["path"]
545
542
  payload = r["payload"]
546
543
  if file_path.endswith("/page.json"):
@@ -577,31 +574,30 @@ class ReportWrapper:
577
574
  A pandas dataframe containing a list of all pages in the report.
578
575
  """
579
576
 
580
- rd = self.rdef
581
- df = pd.DataFrame(
582
- columns=[
583
- "File Path",
584
- "Page Name",
585
- "Page Display Name",
586
- "Hidden",
587
- "Active",
588
- "Width",
589
- "Height",
590
- "Display Option",
591
- "Type",
592
- "Alignment",
593
- "Drillthrough Target Page",
594
- "Visual Count",
595
- "Data Visual Count",
596
- "Visible Visual Count",
597
- "Page Filter Count",
598
- ]
599
- )
577
+ columns = {
578
+ "File Path": "str",
579
+ "Page Name": "str",
580
+ "Page Display Name": "str",
581
+ "Hidden": "bool",
582
+ "Active": "bool",
583
+ "Width": "int",
584
+ "Height": "int",
585
+ "Display Option": "str",
586
+ "Type": "str",
587
+ "Alignment": "str",
588
+ "Drillthrough Target Page": "bool",
589
+ "Visual Count": "int",
590
+ "Data Visual Count": "int",
591
+ "Visible Visual Count": "int",
592
+ "Page Filter Count": "int",
593
+ "Page URL": "str",
594
+ }
595
+ df = _create_dataframe(columns=columns)
600
596
 
601
597
  dfV = self.list_visuals()
602
598
 
603
- page_rows = rd[rd["path"].str.endswith("/page.json")]
604
- pages_row = rd[rd["path"] == "definition/pages/pages.json"]
599
+ page_rows = self.rdef[self.rdef["path"].str.endswith("/page.json")]
600
+ pages_row = self.rdef[self.rdef["path"] == "definition/pages/pages.json"]
605
601
 
606
602
  for _, r in page_rows.iterrows():
607
603
  file_path = r["path"]
@@ -633,9 +629,9 @@ class ReportWrapper:
633
629
  # )
634
630
 
635
631
  visual_count = len(
636
- rd[
637
- rd["path"].str.endswith("/visual.json")
638
- & (rd["path"].str.startswith(page_prefix))
632
+ self.rdef[
633
+ self.rdef["path"].str.endswith("/visual.json")
634
+ & (self.rdef["path"].str.startswith(page_prefix))
639
635
  ]
640
636
  )
641
637
  data_visual_count = len(
@@ -681,23 +677,12 @@ class ReportWrapper:
681
677
 
682
678
  df.loc[df["Page Name"] == activePage, "Active"] = True
683
679
 
684
- int_cols = [
685
- "Width",
686
- "Height",
687
- "Page Filter Count",
688
- "Visual Count",
689
- "Visible Visual Count",
690
- "Data Visual Count",
691
- ]
692
- df[int_cols] = df[int_cols].astype(int)
693
-
694
- bool_cols = ["Hidden", "Active", "Drillthrough Target Page"]
695
- df[bool_cols] = df[bool_cols].astype(bool)
696
-
697
680
  df["Page URL"] = df["Page Name"].apply(
698
681
  lambda page_name: f"{helper.get_web_url(report=self._report, workspace=self._workspace_id)}/{page_name}"
699
682
  )
700
683
 
684
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
685
+
701
686
  return df
702
687
  # return df.style.format({"Page URL": _make_clickable})
703
688
 
@@ -711,39 +696,37 @@ class ReportWrapper:
711
696
  A pandas dataframe containing a list of all visuals in the report.
712
697
  """
713
698
 
714
- rd = self.rdef
715
- df = pd.DataFrame(
716
- columns=[
717
- "File Path",
718
- "Page Name",
719
- "Page Display Name",
720
- "Visual Name",
721
- "Type",
722
- "Display Type",
723
- "X",
724
- "Y",
725
- "Z",
726
- "Width",
727
- "Height",
728
- "Tab Order",
729
- "Hidden",
730
- "Title",
731
- "SubTitle",
732
- "Custom Visual",
733
- "Alt Text",
734
- "Show Items With No Data",
735
- "Divider",
736
- "Slicer Type",
737
- "Row SubTotals",
738
- "Column SubTotals",
739
- "Data Visual",
740
- "Has Sparkline",
741
- "Visual Filter Count",
742
- "Data Limit",
743
- ]
744
- )
699
+ columns = {
700
+ "File Path": "str",
701
+ "Page Name": "str",
702
+ "Page Display Name": "str",
703
+ "Visual Name": "str",
704
+ "Type": "str",
705
+ "Display Type": "str",
706
+ "X": "float",
707
+ "Y": "float",
708
+ "Z": "int",
709
+ "Width": "float",
710
+ "Height": "float",
711
+ "Tab Order": "str",
712
+ "Hidden": "bool",
713
+ "Title": "str",
714
+ "SubTitle": "str",
715
+ "Custom Visual": "bool",
716
+ "Alt Text": "str",
717
+ "Show Items With No Data": "bool",
718
+ "Divider": "str",
719
+ "Slicer Type": "str",
720
+ "Row SubTotals": "bool",
721
+ "Column SubTotals": "bool",
722
+ "Data Visual": "bool",
723
+ "Has Sparkline": "bool",
724
+ "Visual Filter Count": "int",
725
+ "Data Limit": "int",
726
+ }
727
+ df = _create_dataframe(columns=columns)
745
728
 
746
- rd_filt = rd[rd["path"] == "definition/report.json"]
729
+ rd_filt = self.rdef[self.rdef["path"] == "definition/report.json"]
747
730
  payload = rd_filt["payload"].iloc[0]
748
731
  rptJson = _extract_json(rd_filt)
749
732
  custom_visuals = rptJson.get("publicCustomVisuals", [])
@@ -765,7 +748,7 @@ class ReportWrapper:
765
748
 
766
749
  return any(key in all_keys for key in keys_to_check)
767
750
 
768
- for _, r in rd.iterrows():
751
+ for _, r in self.rdef.iterrows():
769
752
  file_path = r["path"]
770
753
  payload = r["payload"]
771
754
  if file_path.endswith("/visual.json"):
@@ -910,16 +893,6 @@ class ReportWrapper:
910
893
  [df, pd.DataFrame(new_data, index=[0])], ignore_index=True
911
894
  )
912
895
 
913
- bool_cols = [
914
- "Hidden",
915
- "Show Items With No Data",
916
- "Custom Visual",
917
- "Data Visual",
918
- "Has Sparkline",
919
- "Row SubTotals",
920
- "Column SubTotals",
921
- ]
922
-
923
896
  grouped_df = (
924
897
  self.list_visual_objects()
925
898
  .groupby(["Page Name", "Visual Name"])
@@ -936,11 +909,7 @@ class ReportWrapper:
936
909
  )
937
910
  df["Visual Object Count"] = df["Visual Object Count"].fillna(0).astype(int)
938
911
 
939
- float_cols = ["X", "Y", "Width", "Height"]
940
- int_cols = ["Z", "Visual Filter Count", "Data Limit", "Visual Object Count"]
941
- df[bool_cols] = df[bool_cols].astype(bool)
942
- df[int_cols] = df[int_cols].astype(int)
943
- df[float_cols] = df[float_cols].astype(float)
912
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
944
913
 
945
914
  return df
946
915
 
@@ -960,23 +929,22 @@ class ReportWrapper:
960
929
  A pandas dataframe containing a list of all semantic model objects used in each visual in the report.
961
930
  """
962
931
 
963
- rd = self.rdef
964
932
  page_mapping, visual_mapping = helper.visual_page_mapping(self)
965
- df = pd.DataFrame(
966
- columns=[
967
- "Page Name",
968
- "Page Display Name",
969
- "Visual Name",
970
- "Table Name",
971
- "Object Name",
972
- "Object Type",
973
- "Implicit Measure",
974
- "Sparkline",
975
- "Visual Calc",
976
- "Format",
977
- "Object Display Name",
978
- ]
979
- )
933
+
934
+ columns = {
935
+ "Page Name": "str",
936
+ "Page Display Name": "str",
937
+ "Visual Name": "str",
938
+ "Table Name": "str",
939
+ "Object Name": "str",
940
+ "Object Type": "str",
941
+ "Implicit Measure": "bool",
942
+ "Sparkline": "bool",
943
+ "Visual Calc": "bool",
944
+ "Format": "str",
945
+ "Object Display Name": "str",
946
+ }
947
+ df = _create_dataframe(columns=columns)
980
948
 
981
949
  def contains_key(data, keys_to_check):
982
950
  if isinstance(data, dict):
@@ -1032,7 +1000,7 @@ class ReportWrapper:
1032
1000
 
1033
1001
  return result
1034
1002
 
1035
- for _, r in rd.iterrows():
1003
+ for _, r in self.rdef.iterrows():
1036
1004
  file_path = r["path"]
1037
1005
  payload = r["payload"]
1038
1006
  if file_path.endswith("/visual.json"):
@@ -1089,8 +1057,7 @@ class ReportWrapper:
1089
1057
  if extended:
1090
1058
  df = self._add_extended(dataframe=df)
1091
1059
 
1092
- bool_cols = ["Implicit Measure", "Sparkline", "Visual Calc"]
1093
- df[bool_cols] = df[bool_cols].astype(bool)
1060
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
1094
1061
 
1095
1062
  return df
1096
1063
 
@@ -1113,16 +1080,15 @@ class ReportWrapper:
1113
1080
 
1114
1081
  from sempy_labs.tom import connect_semantic_model
1115
1082
 
1116
- df = pd.DataFrame(
1117
- columns=[
1118
- "Table Name",
1119
- "Object Name",
1120
- "Object Type",
1121
- "Report Source",
1122
- "Report Source Object",
1123
- ]
1124
- )
1083
+ columns = {
1084
+ "Table Name": "str",
1085
+ "Object Name": "str",
1086
+ "Object Type": "str",
1087
+ "Report Source": "str",
1088
+ "Report Source Object": "str",
1089
+ }
1125
1090
 
1091
+ df = _create_dataframe(columns=columns)
1126
1092
  rf = self.list_report_filters()
1127
1093
  pf = self.list_page_filters()
1128
1094
  vf = self.list_visual_filters()
@@ -1257,17 +1223,17 @@ class ReportWrapper:
1257
1223
  """
1258
1224
 
1259
1225
  rd = self.rdef
1260
- df = pd.DataFrame(
1261
- columns=[
1262
- "File Path",
1263
- "Bookmark Name",
1264
- "Bookmark Display Name",
1265
- "Page Name",
1266
- "Page Display Name",
1267
- "Visual Name",
1268
- "Visual Hidden",
1269
- ]
1270
- )
1226
+
1227
+ columns = {
1228
+ "File Path": "str",
1229
+ "Bookmark Name": "str",
1230
+ "Bookmark Display Name": "str",
1231
+ "Page Name": "str",
1232
+ "Page Display Name": "str",
1233
+ "Visual Name": "str",
1234
+ "Visual Hidden": "bool",
1235
+ }
1236
+ df = _create_dataframe(columns=columns)
1271
1237
 
1272
1238
  bookmark_rows = rd[rd["path"].str.endswith(".bookmark.json")]
1273
1239
 
@@ -1320,8 +1286,7 @@ class ReportWrapper:
1320
1286
  [df, pd.DataFrame(new_data, index=[0])], ignore_index=True
1321
1287
  )
1322
1288
 
1323
- bool_cols = ["Visual Hidden"]
1324
- df[bool_cols] = df[bool_cols].astype(bool)
1289
+ _update_dataframe_datatypes(dataframe=df, column_map=columns)
1325
1290
 
1326
1291
  return df
1327
1292
 
@@ -1338,17 +1303,17 @@ class ReportWrapper:
1338
1303
  A pandas dataframe containing a list of all report-level measures in the report.
1339
1304
  """
1340
1305
 
1341
- df = pd.DataFrame(
1342
- columns=[
1343
- "Measure Name",
1344
- "Table Name",
1345
- "Expression",
1346
- "Data Type",
1347
- "Format String",
1348
- ]
1349
- )
1350
- rd = self.rdef
1351
- rd_filt = rd[rd["path"] == "definition/reportExtensions.json"]
1306
+ columns = {
1307
+ "Measure Name": "str",
1308
+ "Table Name": "str",
1309
+ "Expression": "str",
1310
+ "Data Type": "str",
1311
+ "Format String": "str",
1312
+ }
1313
+
1314
+ df = _create_dataframe(columns=columns)
1315
+
1316
+ rd_filt = self.rdef[self.rdef["path"] == "definition/reportExtensions.json"]
1352
1317
 
1353
1318
  if len(rd_filt) == 1:
1354
1319
  payload = rd_filt["payload"].iloc[0]
@@ -1386,9 +1351,13 @@ class ReportWrapper:
1386
1351
  A pandas dataframe showing a list of report, page and visual annotations in the report.
1387
1352
  """
1388
1353
 
1389
- df = pd.DataFrame(
1390
- columns=["Type", "Object Name", "Annotation Name", "Annotation Value"]
1391
- )
1354
+ columns = {
1355
+ "Type": "str",
1356
+ "Object Name": "str",
1357
+ "Annotation Name": "str",
1358
+ "Annotation Value": "str",
1359
+ }
1360
+ df = _create_dataframe(columns=columns)
1392
1361
 
1393
1362
  page_mapping, visual_mapping = helper.visual_page_mapping(self)
1394
1363
  for _, r in self.rdef.iterrows():
@@ -1454,8 +1423,6 @@ class ReportWrapper:
1454
1423
  Example for web url: file_path = 'https://raw.githubusercontent.com/PowerBiDevCamp/FabricUserApiDemo/main/FabricUserApiDemo/DefinitionTemplates/Shared/Reports/StaticResources/SharedResources/BaseThemes/CY23SU08.json'
1455
1424
  """
1456
1425
 
1457
- import requests
1458
-
1459
1426
  report_path = "definition/report.json"
1460
1427
  theme_version = "5.5.4"
1461
1428
  request_body = {"definition": {"parts": []}}
sempy_labs/tom/_model.py CHANGED
@@ -9,6 +9,7 @@ from sempy_labs._helper_functions import (
9
9
  _make_list_unique,
10
10
  resolve_dataset_name_and_id,
11
11
  resolve_workspace_name_and_id,
12
+ _base_api,
12
13
  )
13
14
  from sempy_labs._list_functions import list_relationships
14
15
  from sempy_labs._refresh_semantic_model import refresh_semantic_model
@@ -17,7 +18,6 @@ from contextlib import contextmanager
17
18
  from typing import List, Iterator, Optional, Union, TYPE_CHECKING
18
19
  from sempy._utils._log import log
19
20
  import sempy_labs._icons as icons
20
- from sempy.fabric.exceptions import FabricHTTPException
21
21
  import ast
22
22
  from uuid import UUID
23
23
  import sempy_labs._authentication as auth
@@ -2965,6 +2965,8 @@ class TOMWrapper:
2965
2965
 
2966
2966
  from sempy_labs._list_functions import list_tables
2967
2967
 
2968
+ fabric.refresh_tom_cache(workspace=self._workspace_id)
2969
+
2968
2970
  dfT = list_tables(
2969
2971
  dataset=self._dataset_id, workspace=self._workspace_id, extended=True
2970
2972
  )
@@ -4518,10 +4520,11 @@ class TOMWrapper:
4518
4520
  "modelItems"
4519
4521
  ].append(new_item)
4520
4522
 
4521
- client = fabric.FabricRestClient()
4522
- response = client.post("/explore/v202304/nl2nl/completions", json=payload)
4523
- if response.status_code != 200:
4524
- raise FabricHTTPException(response)
4523
+ response = _base_api(
4524
+ request="/explore/v202304/nl2nl/completions",
4525
+ method="post",
4526
+ payload=payload,
4527
+ )
4525
4528
 
4526
4529
  for item in response.json().get("modelItems", []):
4527
4530
  ms_name = item["urn"]