semantic-link-labs 0.7.1__py3-none-any.whl → 0.7.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 (35) hide show
  1. {semantic_link_labs-0.7.1.dist-info → semantic_link_labs-0.7.3.dist-info}/METADATA +3 -2
  2. {semantic_link_labs-0.7.1.dist-info → semantic_link_labs-0.7.3.dist-info}/RECORD +35 -28
  3. {semantic_link_labs-0.7.1.dist-info → semantic_link_labs-0.7.3.dist-info}/WHEEL +1 -1
  4. sempy_labs/__init__.py +60 -3
  5. sempy_labs/_bpa_translation/_translations_sv-SE.po +914 -0
  6. sempy_labs/_clear_cache.py +298 -3
  7. sempy_labs/_dataflows.py +130 -0
  8. sempy_labs/_deployment_pipelines.py +171 -0
  9. sempy_labs/_generate_semantic_model.py +148 -27
  10. sempy_labs/_git.py +380 -0
  11. sempy_labs/_helper_functions.py +57 -0
  12. sempy_labs/_list_functions.py +144 -121
  13. sempy_labs/_model_bpa.py +85 -83
  14. sempy_labs/_model_bpa_bulk.py +3 -1
  15. sempy_labs/_model_bpa_rules.py +788 -800
  16. sempy_labs/_query_scale_out.py +15 -3
  17. sempy_labs/_sql.py +96 -0
  18. sempy_labs/_translations.py +0 -1
  19. sempy_labs/_workspace_identity.py +66 -0
  20. sempy_labs/directlake/__init__.py +2 -0
  21. sempy_labs/directlake/_directlake_schema_compare.py +1 -2
  22. sempy_labs/directlake/_dl_helper.py +4 -7
  23. sempy_labs/directlake/_generate_shared_expression.py +85 -0
  24. sempy_labs/directlake/_show_unsupported_directlake_objects.py +1 -2
  25. sempy_labs/lakehouse/_get_lakehouse_tables.py +7 -3
  26. sempy_labs/migration/_migrate_calctables_to_lakehouse.py +5 -0
  27. sempy_labs/migration/_migrate_calctables_to_semantic_model.py +5 -0
  28. sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +6 -2
  29. sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +6 -5
  30. sempy_labs/migration/_migration_validation.py +6 -0
  31. sempy_labs/report/_report_functions.py +21 -42
  32. sempy_labs/report/_report_rebind.py +5 -0
  33. sempy_labs/tom/_model.py +91 -52
  34. {semantic_link_labs-0.7.1.dist-info → semantic_link_labs-0.7.3.dist-info}/LICENSE +0 -0
  35. {semantic_link_labs-0.7.1.dist-info → semantic_link_labs-0.7.3.dist-info}/top_level.txt +0 -0
sempy_labs/tom/_model.py CHANGED
@@ -230,6 +230,7 @@ class TOMWrapper:
230
230
  description: Optional[str] = None,
231
231
  display_folder: Optional[str] = None,
232
232
  format_string_expression: Optional[str] = None,
233
+ source_lineage_tag: Optional[str] = None,
233
234
  ):
234
235
  """
235
236
  Adds a measure to the semantic model.
@@ -252,6 +253,8 @@ class TOMWrapper:
252
253
  The display folder in which the measure will reside.
253
254
  format_string_expression : str, default=None
254
255
  The format string expression.
256
+ source_lineage_tag : str, default=None
257
+ A tag that represents the lineage of the source for the object.
255
258
  """
256
259
  import Microsoft.AnalysisServices.Tabular as TOM
257
260
 
@@ -269,6 +272,8 @@ class TOMWrapper:
269
272
  fsd = TOM.FormatStringDefinition()
270
273
  fsd.Expression = format_string_expression
271
274
  obj.FormatStringDefinition = fsd
275
+ if source_lineage_tag is not None:
276
+ obj.SourceLineageTag = source_lineage_tag
272
277
 
273
278
  self.model.Tables[table_name].Measures.Add(obj)
274
279
 
@@ -285,6 +290,7 @@ class TOMWrapper:
285
290
  data_category: Optional[str] = None,
286
291
  key: Optional[bool] = False,
287
292
  summarize_by: Optional[str] = None,
293
+ source_lineage_tag: Optional[str] = None,
288
294
  ):
289
295
  """
290
296
  Adds a calculated table column to a calculated table within a semantic model.
@@ -314,6 +320,8 @@ class TOMWrapper:
314
320
  summarize_by : str, default=None
315
321
  Sets the value for the Summarize By property of the column.
316
322
  Defaults to None resolves to 'Default'.
323
+ source_lineage_tag : str, default=None
324
+ A tag that represents the lineage of the source for the object.
317
325
  """
318
326
  import Microsoft.AnalysisServices.Tabular as TOM
319
327
  import System
@@ -346,6 +354,8 @@ class TOMWrapper:
346
354
  obj.DisplayFolder = display_folder
347
355
  if data_category is not None:
348
356
  obj.DataCategory = data_category
357
+ if source_lineage_tag is not None:
358
+ obj.SourceLineageTag = source_lineage_tag
349
359
  self.model.Tables[table_name].Columns.Add(obj)
350
360
 
351
361
  def add_data_column(
@@ -361,6 +371,7 @@ class TOMWrapper:
361
371
  data_category: Optional[str] = None,
362
372
  key: Optional[bool] = False,
363
373
  summarize_by: Optional[str] = None,
374
+ source_lineage_tag: Optional[str] = None,
364
375
  ):
365
376
  """
366
377
  Adds a data column to a table within a semantic model.
@@ -390,6 +401,8 @@ class TOMWrapper:
390
401
  summarize_by : str, default=None
391
402
  Sets the value for the Summarize By property of the column.
392
403
  Defaults to None resolves to 'Default'.
404
+ source_lineage_tag : str, default=None
405
+ A tag that represents the lineage of the source for the object.
393
406
  """
394
407
  import Microsoft.AnalysisServices.Tabular as TOM
395
408
  import System
@@ -422,6 +435,8 @@ class TOMWrapper:
422
435
  obj.DisplayFolder = display_folder
423
436
  if data_category is not None:
424
437
  obj.DataCategory = data_category
438
+ if source_lineage_tag is not None:
439
+ obj.SourceLineageTag = source_lineage_tag
425
440
  self.model.Tables[table_name].Columns.Add(obj)
426
441
 
427
442
  def add_calculated_column(
@@ -437,6 +452,7 @@ class TOMWrapper:
437
452
  data_category: Optional[str] = None,
438
453
  key: Optional[bool] = False,
439
454
  summarize_by: Optional[str] = None,
455
+ source_lineage_tag: Optional[str] = None,
440
456
  ):
441
457
  """
442
458
  Adds a calculated column to a table within a semantic model.
@@ -466,6 +482,8 @@ class TOMWrapper:
466
482
  summarize_by : str, default=None
467
483
  Sets the value for the Summarize By property of the column.
468
484
  Defaults to None which resolves to 'Default'.
485
+ source_lineage_tag : str, default=None
486
+ A tag that represents the lineage of the source for the object.
469
487
  """
470
488
  import Microsoft.AnalysisServices.Tabular as TOM
471
489
  import System
@@ -498,6 +516,8 @@ class TOMWrapper:
498
516
  obj.DisplayFolder = display_folder
499
517
  if data_category is not None:
500
518
  obj.DataCategory = data_category
519
+ if source_lineage_tag is not None:
520
+ obj.SourceLineageTag = source_lineage_tag
501
521
  self.model.Tables[table_name].Columns.Add(obj)
502
522
 
503
523
  def add_calculation_item(
@@ -657,6 +677,7 @@ class TOMWrapper:
657
677
  levels: Optional[List[str]] = None,
658
678
  hierarchy_description: Optional[str] = None,
659
679
  hierarchy_hidden: Optional[bool] = False,
680
+ source_lineage_tag: Optional[str] = None,
660
681
  ):
661
682
  """
662
683
  Adds a `hierarchy <https://learn.microsoft.com/dotnet/api/microsoft.analysisservices.hierarchy?view=analysisservices-dotnet>`_ to a table within a semantic model.
@@ -675,6 +696,8 @@ class TOMWrapper:
675
696
  A description of the hierarchy.
676
697
  hierarchy_hidden : bool, default=False
677
698
  Whether the hierarchy is visible or hidden.
699
+ source_lineage_tag : str, default=None
700
+ A tag that represents the lineage of the source for the object.
678
701
  """
679
702
  import Microsoft.AnalysisServices.Tabular as TOM
680
703
 
@@ -701,6 +724,8 @@ class TOMWrapper:
701
724
  obj.IsHidden = hierarchy_hidden
702
725
  if hierarchy_description is not None:
703
726
  obj.Description = hierarchy_description
727
+ if source_lineage_tag is not None:
728
+ obj.SourceLineageTag = source_lineage_tag
704
729
  self.model.Tables[table_name].Hierarchies.Add(obj)
705
730
 
706
731
  for col in columns:
@@ -846,7 +871,7 @@ class TOMWrapper:
846
871
  self.model.Tables.Add(tbl)
847
872
 
848
873
  def add_expression(
849
- self, name: str, expression: str, description: Optional[str] = None
874
+ self, name: str, expression: str, description: Optional[str] = None, source_lineage_tag: Optional[str] = None,
850
875
  ):
851
876
  """
852
877
  Adds an `expression <https://learn.microsoft.com/dotnet/api/microsoft.analysisservices.tabular.namedexpression?view=analysisservices-dotnet>`_ to a semantic model.
@@ -859,6 +884,8 @@ class TOMWrapper:
859
884
  The M expression of the expression.
860
885
  description : str, default=None
861
886
  A description of the expression.
887
+ source_lineage_tag : str, default=None
888
+ A tag that represents the lineage of the source for the object.
862
889
  """
863
890
  import Microsoft.AnalysisServices.Tabular as TOM
864
891
 
@@ -866,6 +893,8 @@ class TOMWrapper:
866
893
  exp.Name = name
867
894
  if description is not None:
868
895
  exp.Description = description
896
+ if source_lineage_tag is not None:
897
+ exp.SourceLineageTag = source_lineage_tag
869
898
  exp.Kind = TOM.ExpressionKind.M
870
899
  exp.Expression = expression
871
900
 
@@ -2495,6 +2524,7 @@ class TOMWrapper:
2495
2524
  description: Optional[str] = None,
2496
2525
  data_category: Optional[str] = None,
2497
2526
  hidden: Optional[bool] = False,
2527
+ source_lineage_tag: Optional[str] = None,
2498
2528
  ):
2499
2529
  """
2500
2530
  Adds a table to the semantic model.
@@ -2509,6 +2539,8 @@ class TOMWrapper:
2509
2539
  The data category for the table.
2510
2540
  hidden : bool, default=False
2511
2541
  Whether the table is hidden or visible.
2542
+ source_lineage_tag : str, default=None
2543
+ A tag that represents the lineage of the source for the object.
2512
2544
  """
2513
2545
  import Microsoft.AnalysisServices.Tabular as TOM
2514
2546
 
@@ -2518,6 +2550,8 @@ class TOMWrapper:
2518
2550
  t.Description = description
2519
2551
  if data_category is not None:
2520
2552
  t.DataCategory = data_category
2553
+ if source_lineage_tag is not None:
2554
+ t.SourceLineageTag = source_lineage_tag
2521
2555
  t.Hidden = hidden
2522
2556
  self.model.Tables.Add(t)
2523
2557
 
@@ -2707,27 +2741,17 @@ class TOMWrapper:
2707
2741
  Saves Vertipaq Analyzer statistics as annotations on objects in the semantic model.
2708
2742
  """
2709
2743
 
2710
- dfT = fabric.list_tables(
2744
+ from sempy_labs._list_functions import list_tables
2745
+
2746
+ dfT = list_tables(
2711
2747
  dataset=self._dataset, workspace=self._workspace, extended=True
2712
2748
  )
2713
2749
  dfC = fabric.list_columns(
2714
2750
  dataset=self._dataset, workspace=self._workspace, extended=True
2715
2751
  )
2716
- # intList = ['Total Size']#, 'Data Size', 'Dictionary Size', 'Hierarchy Size']
2717
- dfCSum = dfC.groupby(["Table Name"])["Total Size"].sum().reset_index()
2718
- dfTable = pd.merge(
2719
- dfT[["Name", "Type", "Row Count"]],
2720
- dfCSum[["Table Name", "Total Size"]],
2721
- left_on="Name",
2722
- right_on="Table Name",
2723
- how="inner",
2724
- )
2725
2752
  dfP = fabric.list_partitions(
2726
2753
  dataset=self._dataset, workspace=self._workspace, extended=True
2727
2754
  )
2728
- dfP["Records per Segment"] = round(
2729
- dfP["Record Count"] / dfP["Segment Count"], 2
2730
- )
2731
2755
  dfH = fabric.list_hierarchies(
2732
2756
  dataset=self._dataset, workspace=self._workspace, extended=True
2733
2757
  )
@@ -2736,58 +2760,73 @@ class TOMWrapper:
2736
2760
  )
2737
2761
 
2738
2762
  for t in self.model.Tables:
2739
- dfT_filt = dfTable[dfTable["Name"] == t.Name]
2740
- rowCount = str(dfT_filt["Row Count"].iloc[0])
2741
- totalSize = str(dfT_filt["Total Size"].iloc[0])
2742
- self.set_annotation(object=t, name="Vertipaq_RowCount", value=rowCount)
2743
- self.set_annotation(object=t, name="Vertipaq_TableSize", value=totalSize)
2763
+ dfT_filt = dfT[dfT["Name"] == t.Name]
2764
+ if len(dfT_filt) > 0:
2765
+ row = dfT_filt.iloc[0]
2766
+ rowCount = str(row["Row Count"])
2767
+ totalSize = str(row["Total Size"])
2768
+ self.set_annotation(object=t, name="Vertipaq_RowCount", value=rowCount)
2769
+ self.set_annotation(
2770
+ object=t, name="Vertipaq_TableSize", value=totalSize
2771
+ )
2744
2772
  for c in t.Columns:
2745
2773
  dfC_filt = dfC[
2746
2774
  (dfC["Table Name"] == t.Name) & (dfC["Column Name"] == c.Name)
2747
2775
  ]
2748
- totalSize = str(dfC_filt["Total Size"].iloc[0])
2749
- dataSize = str(dfC_filt["Data Size"].iloc[0])
2750
- dictSize = str(dfC_filt["Dictionary Size"].iloc[0])
2751
- hierSize = str(dfC_filt["Hierarchy Size"].iloc[0])
2752
- card = str(dfC_filt["Column Cardinality"].iloc[0])
2753
- self.set_annotation(
2754
- object=c, name="Vertipaq_TotalSize", value=totalSize
2755
- )
2756
- self.set_annotation(object=c, name="Vertipaq_DataSize", value=dataSize)
2757
- self.set_annotation(
2758
- object=c, name="Vertipaq_DictionarySize", value=dictSize
2759
- )
2760
- self.set_annotation(
2761
- object=c, name="Vertipaq_HierarchySize", value=hierSize
2762
- )
2763
- self.set_annotation(object=c, name="Vertipaq_Cardinality", value=card)
2776
+ if len(dfC_filt) > 0:
2777
+ row = dfC_filt.iloc[0]
2778
+ totalSize = str(row["Total Size"])
2779
+ dataSize = str(row["Data Size"])
2780
+ dictSize = str(row["Dictionary Size"])
2781
+ hierSize = str(row["Hierarchy Size"])
2782
+ card = str(row["Column Cardinality"])
2783
+ self.set_annotation(
2784
+ object=c, name="Vertipaq_TotalSize", value=totalSize
2785
+ )
2786
+ self.set_annotation(
2787
+ object=c, name="Vertipaq_DataSize", value=dataSize
2788
+ )
2789
+ self.set_annotation(
2790
+ object=c, name="Vertipaq_DictionarySize", value=dictSize
2791
+ )
2792
+ self.set_annotation(
2793
+ object=c, name="Vertipaq_HierarchySize", value=hierSize
2794
+ )
2795
+ self.set_annotation(
2796
+ object=c, name="Vertipaq_Cardinality", value=card
2797
+ )
2764
2798
  for p in t.Partitions:
2765
2799
  dfP_filt = dfP[
2766
2800
  (dfP["Table Name"] == t.Name) & (dfP["Partition Name"] == p.Name)
2767
2801
  ]
2768
- recordCount = str(dfP_filt["Record Count"].iloc[0])
2769
- segmentCount = str(dfP_filt["Segment Count"].iloc[0])
2770
- rpS = str(dfP_filt["Records per Segment"].iloc[0])
2771
- self.set_annotation(
2772
- object=p, name="Vertipaq_RecordCount", value=recordCount
2773
- )
2774
- self.set_annotation(
2775
- object=p, name="Vertipaq_SegmentCount", value=segmentCount
2776
- )
2777
- self.set_annotation(
2778
- object=p, name="Vertipaq_RecordsPerSegment", value=rpS
2779
- )
2802
+ if len(dfP_filt) > 0:
2803
+ row = dfP_filt.iloc[0]
2804
+ recordCount = str(row["Record Count"])
2805
+ segmentCount = str(row["Segment Count"])
2806
+ rpS = str(row["Records per Segment"])
2807
+ self.set_annotation(
2808
+ object=p, name="Vertipaq_RecordCount", value=recordCount
2809
+ )
2810
+ self.set_annotation(
2811
+ object=p, name="Vertipaq_SegmentCount", value=segmentCount
2812
+ )
2813
+ self.set_annotation(
2814
+ object=p, name="Vertipaq_RecordsPerSegment", value=rpS
2815
+ )
2780
2816
  for h in t.Hierarchies:
2781
2817
  dfH_filt = dfH[
2782
2818
  (dfH["Table Name"] == t.Name) & (dfH["Hierarchy Name"] == h.Name)
2783
2819
  ]
2784
- usedSize = str(dfH_filt["Used Size"].iloc[0])
2785
- self.set_annotation(object=h, name="Vertipaq_UsedSize", value=usedSize)
2820
+ if len(dfH_filt) > 0:
2821
+ usedSize = str(dfH_filt["Used Size"].iloc[0])
2822
+ self.set_annotation(
2823
+ object=h, name="Vertipaq_UsedSize", value=usedSize
2824
+ )
2786
2825
  for r in self.model.Relationships:
2787
2826
  dfR_filt = dfR[dfR["Relationship Name"] == r.Name]
2788
- relSize = str(dfR_filt["Used Size"].iloc[0])
2789
- self.set_annotation(object=r, name="Vertipaq_UsedSize", value=relSize)
2790
-
2827
+ if len(dfR_filt) > 0:
2828
+ relSize = str(dfR_filt["Used Size"].iloc[0])
2829
+ self.set_annotation(object=r, name="Vertipaq_UsedSize", value=relSize)
2791
2830
  try:
2792
2831
  runId = self.get_annotation_value(object=self.model, name="Vertipaq_Run")
2793
2832
  runId = str(int(runId) + 1)