semantic-link-labs 0.12.3__py3-none-any.whl → 0.12.4__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.
- {semantic_link_labs-0.12.3.dist-info → semantic_link_labs-0.12.4.dist-info}/METADATA +4 -3
- {semantic_link_labs-0.12.3.dist-info → semantic_link_labs-0.12.4.dist-info}/RECORD +35 -29
- sempy_labs/__init__.py +10 -8
- sempy_labs/_a_lib_info.py +1 -1
- sempy_labs/_authentication.py +1 -1
- sempy_labs/_capacities.py +1 -1
- sempy_labs/_git.py +1 -1
- sempy_labs/_helper_functions.py +27 -4
- sempy_labs/_list_functions.py +55 -5
- sempy_labs/_managed_private_endpoints.py +1 -1
- sempy_labs/_notebooks.py +4 -2
- sempy_labs/_sql_audit_settings.py +208 -0
- sempy_labs/_sql_endpoints.py +18 -3
- sempy_labs/_utils.py +2 -0
- sempy_labs/admin/__init__.py +6 -0
- sempy_labs/admin/_items.py +3 -3
- sempy_labs/admin/_labels.py +211 -0
- sempy_labs/directlake/_warm_cache.py +3 -1
- sempy_labs/eventstream/__init__.py +37 -0
- sempy_labs/eventstream/_items.py +263 -0
- sempy_labs/eventstream/_topology.py +652 -0
- sempy_labs/graph/__init__.py +8 -0
- sempy_labs/graph/_groups.py +60 -53
- sempy_labs/graph/_sensitivity_labels.py +39 -0
- sempy_labs/graph/_teams.py +19 -18
- sempy_labs/graph/_user_licenses.py +96 -0
- sempy_labs/graph/_users.py +23 -16
- sempy_labs/lakehouse/_get_lakehouse_tables.py +33 -1
- sempy_labs/lakehouse/_lakehouse.py +6 -2
- sempy_labs/lakehouse/_partitioning.py +165 -0
- sempy_labs/report/_reportwrapper.py +15 -5
- sempy_labs/tom/_model.py +81 -4
- sempy_labs/_eventstreams.py +0 -123
- {semantic_link_labs-0.12.3.dist-info → semantic_link_labs-0.12.4.dist-info}/WHEEL +0 -0
- {semantic_link_labs-0.12.3.dist-info → semantic_link_labs-0.12.4.dist-info}/licenses/LICENSE +0 -0
- {semantic_link_labs-0.12.3.dist-info → semantic_link_labs-0.12.4.dist-info}/top_level.txt +0 -0
|
@@ -1886,7 +1886,6 @@ class ReportWrapper:
|
|
|
1886
1886
|
)
|
|
1887
1887
|
|
|
1888
1888
|
self._ensure_pbir()
|
|
1889
|
-
theme_version = "5.6.4"
|
|
1890
1889
|
|
|
1891
1890
|
# Extract theme_json from theme_file_path
|
|
1892
1891
|
if theme_file_path:
|
|
@@ -1912,14 +1911,25 @@ class ReportWrapper:
|
|
|
1912
1911
|
theme_name_full = f"{theme_name}.json"
|
|
1913
1912
|
|
|
1914
1913
|
# Add theme.json file
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1914
|
+
try:
|
|
1915
|
+
self.add(
|
|
1916
|
+
file_path=f"StaticResources/RegisteredResources/{theme_name_full}",
|
|
1917
|
+
payload=theme_json,
|
|
1918
|
+
)
|
|
1919
|
+
except Exception:
|
|
1920
|
+
self.update(
|
|
1921
|
+
file_path=f"StaticResources/RegisteredResources/{theme_name_full}",
|
|
1922
|
+
payload=theme_json,
|
|
1923
|
+
)
|
|
1924
|
+
|
|
1925
|
+
rpt_version_at_import = self.get(
|
|
1926
|
+
file_path=self._report_file_path,
|
|
1927
|
+
json_path="$.themeCollection.baseTheme.reportVersionAtImport",
|
|
1918
1928
|
)
|
|
1919
1929
|
|
|
1920
1930
|
custom_theme = {
|
|
1921
1931
|
"name": theme_name_full,
|
|
1922
|
-
"reportVersionAtImport":
|
|
1932
|
+
"reportVersionAtImport": rpt_version_at_import,
|
|
1923
1933
|
"type": "RegisteredResources",
|
|
1924
1934
|
}
|
|
1925
1935
|
|
sempy_labs/tom/_model.py
CHANGED
|
@@ -151,7 +151,12 @@ class TOMWrapper:
|
|
|
151
151
|
|
|
152
152
|
self._table_map = {}
|
|
153
153
|
self._column_map = {}
|
|
154
|
-
self._compat_level = self.model.
|
|
154
|
+
self._compat_level = self.model.Database.CompatibilityLevel
|
|
155
|
+
|
|
156
|
+
# Max compat level
|
|
157
|
+
s = self.model.Server.SupportedCompatibilityLevels
|
|
158
|
+
nums = [int(x) for x in s.split(",") if x.strip() != "1000000"]
|
|
159
|
+
self._max_compat_level = max(nums)
|
|
155
160
|
|
|
156
161
|
# Minimum campat level for lineage tags is 1540 (https://learn.microsoft.com/dotnet/api/microsoft.analysisservices.tabular.table.lineagetag?view=analysisservices-dotnet#microsoft-analysisservices-tabular-table-lineagetag)
|
|
157
162
|
if self._compat_level >= 1540:
|
|
@@ -240,6 +245,22 @@ class TOMWrapper:
|
|
|
240
245
|
if t.CalculationGroup is not None:
|
|
241
246
|
yield t
|
|
242
247
|
|
|
248
|
+
def all_functions(self):
|
|
249
|
+
"""
|
|
250
|
+
Outputs a list of all user-defined functions in the semantic model.
|
|
251
|
+
|
|
252
|
+
Parameters
|
|
253
|
+
----------
|
|
254
|
+
|
|
255
|
+
Returns
|
|
256
|
+
-------
|
|
257
|
+
Iterator[Microsoft.AnalysisServices.Tabular.Function]
|
|
258
|
+
All user-defined functions within the semantic model.
|
|
259
|
+
"""
|
|
260
|
+
|
|
261
|
+
for f in self.model.Functions:
|
|
262
|
+
yield f
|
|
263
|
+
|
|
243
264
|
def all_measures(self):
|
|
244
265
|
"""
|
|
245
266
|
Outputs a list of all measures in the semantic model.
|
|
@@ -759,6 +780,60 @@ class TOMWrapper:
|
|
|
759
780
|
obj.Description = description
|
|
760
781
|
self.model.Roles.Add(obj)
|
|
761
782
|
|
|
783
|
+
def set_compatibility_level(self, compatibility_level: int):
|
|
784
|
+
"""
|
|
785
|
+
Sets compatibility level of the semantic model
|
|
786
|
+
|
|
787
|
+
Parameters
|
|
788
|
+
----------
|
|
789
|
+
compatibility_level : int
|
|
790
|
+
The compatibility level to set the for the semantic model.
|
|
791
|
+
"""
|
|
792
|
+
import Microsoft.AnalysisServices.Tabular as TOM
|
|
793
|
+
|
|
794
|
+
if compatibility_level < 1500 or compatibility_level > self._max_compat_level:
|
|
795
|
+
raise ValueError(
|
|
796
|
+
f"{icons.red_dot} Compatibility level must be between 1500 and {self._max_compat_level}."
|
|
797
|
+
)
|
|
798
|
+
if self._compat_level > compatibility_level:
|
|
799
|
+
print(
|
|
800
|
+
f"{icons.warning} Compatibility level can only be increased, not decreased."
|
|
801
|
+
)
|
|
802
|
+
return
|
|
803
|
+
|
|
804
|
+
self.model.Database.CompatibilityLevel = compatibility_level
|
|
805
|
+
bim = TOM.JsonScripter.ScriptCreateOrReplace(self.model.Database)
|
|
806
|
+
fabric.execute_tmsl(script=bim, workspace=self._workspace_id)
|
|
807
|
+
|
|
808
|
+
def set_user_defined_function(self, name: str, expression: str):
|
|
809
|
+
"""
|
|
810
|
+
Sets the definition of a `user-defined <https://learn.microsoft.com/en-us/dax/best-practices/dax-user-defined-functions#using-model-explorer>_` function within the semantic model. This function requires that the compatibility level is at least 1702.
|
|
811
|
+
|
|
812
|
+
Parameters
|
|
813
|
+
----------
|
|
814
|
+
name : str
|
|
815
|
+
Name of the user-defined function.
|
|
816
|
+
expression : str
|
|
817
|
+
The DAX expression for the user-defined function.
|
|
818
|
+
"""
|
|
819
|
+
import Microsoft.AnalysisServices.Tabular as TOM
|
|
820
|
+
|
|
821
|
+
if self._compat_level < 1702:
|
|
822
|
+
raise ValueError(
|
|
823
|
+
f"{icons.warning} User-defined functions require a compatibility level of at least 1702. The current compatibility level is {self._compat_level}. Use the 'tom.set_compatibility_level' function to change the compatibility level."
|
|
824
|
+
)
|
|
825
|
+
|
|
826
|
+
existing = [f.Name for f in self.model.Functions]
|
|
827
|
+
|
|
828
|
+
if name in existing:
|
|
829
|
+
self.model.Functions[name].Expression = expression
|
|
830
|
+
else:
|
|
831
|
+
obj = TOM.Function()
|
|
832
|
+
obj.Name = name
|
|
833
|
+
obj.Expression = expression
|
|
834
|
+
obj.LineageTag = generate_guid()
|
|
835
|
+
self.model.Functions.Add(obj)
|
|
836
|
+
|
|
762
837
|
def set_rls(self, role_name: str, table_name: str, filter_expression: str):
|
|
763
838
|
"""
|
|
764
839
|
Sets the row level security permissions for a table within a role.
|
|
@@ -1908,6 +1983,8 @@ class TOMWrapper:
|
|
|
1908
1983
|
object.Parent.CalculationItems.Remove(object.Name)
|
|
1909
1984
|
elif objType == TOM.ObjectType.TablePermission:
|
|
1910
1985
|
object.Parent.TablePermissions.Remove(object.Name)
|
|
1986
|
+
elif objType == TOM.ObjectType.Function:
|
|
1987
|
+
object.Parent.Functions.Remove(object.Name)
|
|
1911
1988
|
|
|
1912
1989
|
def used_in_relationships(self, object: Union["TOM.Table", "TOM.Column"]):
|
|
1913
1990
|
"""
|
|
@@ -4749,8 +4826,8 @@ class TOMWrapper:
|
|
|
4749
4826
|
value_filter_behavior = value_filter_behavior.capitalize()
|
|
4750
4827
|
min_compat = 1606
|
|
4751
4828
|
|
|
4752
|
-
if self.model.
|
|
4753
|
-
self.model.
|
|
4829
|
+
if self.model.Database.CompatibilityLevel < min_compat:
|
|
4830
|
+
self.model.Database.CompatibilityLevel = min_compat
|
|
4754
4831
|
|
|
4755
4832
|
self.model.ValueFilterBehavior = System.Enum.Parse(
|
|
4756
4833
|
TOM.ValueFilterBehaviorType, value_filter_behavior
|
|
@@ -5840,7 +5917,7 @@ class TOMWrapper:
|
|
|
5840
5917
|
import Microsoft.AnalysisServices.Tabular as TOM
|
|
5841
5918
|
|
|
5842
5919
|
# ChangedProperty logic (min compat level is 1567) https://learn.microsoft.com/dotnet/api/microsoft.analysisservices.tabular.changedproperty?view=analysisservices-dotnet
|
|
5843
|
-
if self.model.
|
|
5920
|
+
if self.model.Database.CompatibilityLevel >= 1567:
|
|
5844
5921
|
for t in self.model.Tables:
|
|
5845
5922
|
if any(
|
|
5846
5923
|
p.SourceType == TOM.PartitionSourceType.Entity
|
sempy_labs/_eventstreams.py
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import pandas as pd
|
|
2
|
-
from typing import Optional
|
|
3
|
-
from sempy_labs._helper_functions import (
|
|
4
|
-
_base_api,
|
|
5
|
-
delete_item,
|
|
6
|
-
_create_dataframe,
|
|
7
|
-
create_item,
|
|
8
|
-
resolve_workspace_id,
|
|
9
|
-
)
|
|
10
|
-
from uuid import UUID
|
|
11
|
-
import sempy_labs._icons as icons
|
|
12
|
-
from sempy._utils._log import log
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@log
|
|
16
|
-
def list_eventstreams(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
|
|
17
|
-
"""
|
|
18
|
-
Shows the eventstreams within a workspace.
|
|
19
|
-
|
|
20
|
-
This is a wrapper function for the following API: `Items - List Eventstreams <https://learn.microsoft.com/rest/api/fabric/environment/items/list-eventstreams>`_.
|
|
21
|
-
|
|
22
|
-
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
23
|
-
|
|
24
|
-
Parameters
|
|
25
|
-
----------
|
|
26
|
-
workspace : str | uuid.UUID, default=None
|
|
27
|
-
The Fabric workspace name or ID.
|
|
28
|
-
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
29
|
-
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
30
|
-
|
|
31
|
-
Returns
|
|
32
|
-
-------
|
|
33
|
-
pandas.DataFrame
|
|
34
|
-
A pandas dataframe showing the eventstreams within a workspace.
|
|
35
|
-
"""
|
|
36
|
-
|
|
37
|
-
columns = {
|
|
38
|
-
"Eventstream Name": "string",
|
|
39
|
-
"Eventstream Id": "string",
|
|
40
|
-
"Description": "string",
|
|
41
|
-
}
|
|
42
|
-
df = _create_dataframe(columns=columns)
|
|
43
|
-
|
|
44
|
-
workspace_id = resolve_workspace_id(workspace)
|
|
45
|
-
responses = _base_api(
|
|
46
|
-
request=f"/v1/workspaces/{workspace_id}/eventstreams",
|
|
47
|
-
uses_pagination=True,
|
|
48
|
-
client="fabric_sp",
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
rows = []
|
|
52
|
-
for r in responses:
|
|
53
|
-
for v in r.get("value", []):
|
|
54
|
-
rows.append(
|
|
55
|
-
{
|
|
56
|
-
"Eventstream Name": v.get("displayName"),
|
|
57
|
-
"Eventstream Id": v.get("id"),
|
|
58
|
-
"Description": v.get("description"),
|
|
59
|
-
}
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
if rows:
|
|
63
|
-
df = pd.DataFrame(rows, columns=list(columns.keys()))
|
|
64
|
-
|
|
65
|
-
return df
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
@log
|
|
69
|
-
def create_eventstream(
|
|
70
|
-
name: str, description: Optional[str] = None, workspace: Optional[str | UUID] = None
|
|
71
|
-
):
|
|
72
|
-
"""
|
|
73
|
-
Creates a Fabric eventstream.
|
|
74
|
-
|
|
75
|
-
This is a wrapper function for the following API: `Items - Create Eventstream <https://learn.microsoft.com/rest/api/fabric/environment/items/create-eventstream>`_.
|
|
76
|
-
|
|
77
|
-
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
78
|
-
|
|
79
|
-
Parameters
|
|
80
|
-
----------
|
|
81
|
-
name: str
|
|
82
|
-
Name of the eventstream.
|
|
83
|
-
description : str, default=None
|
|
84
|
-
A description of the environment.
|
|
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(
|
|
92
|
-
name=name, description=description, type="Eventstream", workspace=workspace
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
@log
|
|
97
|
-
def delete_eventstream(
|
|
98
|
-
eventstream: str | UUID, workspace: Optional[str | UUID] = None, **kwargs
|
|
99
|
-
):
|
|
100
|
-
"""
|
|
101
|
-
Deletes a Fabric eventstream.
|
|
102
|
-
|
|
103
|
-
This is a wrapper function for the following API: `Items - Delete Eventstream <https://learn.microsoft.com/rest/api/fabric/environment/items/delete-eventstream>`_.
|
|
104
|
-
|
|
105
|
-
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
106
|
-
|
|
107
|
-
Parameters
|
|
108
|
-
----------
|
|
109
|
-
eventstream: str | uuid.UUID
|
|
110
|
-
Name or ID of the eventstream.
|
|
111
|
-
workspace : str | uuid.UUID, default=None
|
|
112
|
-
The Fabric workspace name or ID.
|
|
113
|
-
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
114
|
-
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
115
|
-
"""
|
|
116
|
-
|
|
117
|
-
if "name" in kwargs:
|
|
118
|
-
eventstream = kwargs["name"]
|
|
119
|
-
print(
|
|
120
|
-
f"{icons.warning} The 'name' parameter is deprecated. Please use 'eventstream' instead."
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
delete_item(item=eventstream, type="Eventstream", workspace=workspace)
|
|
File without changes
|
{semantic_link_labs-0.12.3.dist-info → semantic_link_labs-0.12.4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|