Skip to content

Commit

Permalink
fixed up changes per merge
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kovalsky committed Oct 1, 2024
1 parent ed8c95b commit 0edf9b3
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 13 deletions.
14 changes: 10 additions & 4 deletions src/sempy_labs/_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,9 @@ def resolve_warehouse_id(warehouse: str, workspace: Optional[str]) -> UUID:
"""

workspace = fabric.resolve_workspace_name(workspace)
return fabric.resolve_item_id(item_name=warehouse, type='Warehouse', workspace=workspace)
return fabric.resolve_item_id(
item_name=warehouse, type="Warehouse", workspace=workspace
)


def get_language_codes(languages: str | List[str]):
Expand Down Expand Up @@ -1048,7 +1050,7 @@ def get_azure_token_credentials(

def convert_to_alphanumeric_lowercase(input_string):

# Removes non-alphanumeric characters
# Removes non-alphanumeric characters
cleaned_string = re.sub(r"[^a-zA-Z0-9]", "", input_string)
cleaned_string = cleaned_string.lower()

Expand All @@ -1071,7 +1073,9 @@ def resolve_environment_id(environment: str, workspace: Optional[str] = None) ->
"""

workspace = fabric.resolve_workspace_name(workspace)
return fabric.resolve_item_id(item_name=environment, type='Environment', workspace=workspace)
return fabric.resolve_item_id(
item_name=environment, type="Environment", workspace=workspace
)


def make_clickable(val):
Expand Down Expand Up @@ -1119,7 +1123,9 @@ def resolve_notebook_id(notebook: str, workspace: Optional[str] = None) -> UUID:
"""

workspace = fabric.resolve_workspace_name(workspace)
return fabric.resolve_item_id(item_name=notebook, type='Notebook', workspace=workspace)
return fabric.resolve_item_id(
item_name=notebook, type="Notebook", workspace=workspace
)


def generate_guid():
Expand Down
16 changes: 12 additions & 4 deletions src/sempy_labs/_model_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ def get_measure_dependencies(
"Object Type": r["Object Type"],
"Referenced Object": dependency.iloc[4],
"Referenced Table": dependency.iloc[3],
"Referenced Object Type": dependency.iloc[5],
"Referenced Object Type": dependency.iloc[
5
],
"Done": d,
"Full Object Name": r["Full Object Name"],
"Referenced Full Object Name": dependency.iloc[
Expand All @@ -112,7 +114,9 @@ def get_measure_dependencies(
"Object Type": r["Object Type"],
"Referenced Object": dependency.iloc[4],
"Referenced Table": dependency.iloc[3],
"Referenced Object Type": dependency.iloc[5],
"Referenced Object Type": dependency.iloc[
5
],
"Done": d,
"Full Object Name": r["Full Object Name"],
"Referenced Full Object Name": dependency.iloc[
Expand Down Expand Up @@ -216,7 +220,9 @@ def get_model_calc_dependencies(
"Object Type": r["Object Type"],
"Referenced Object": dependency.iloc[4],
"Referenced Table": dependency.iloc[3],
"Referenced Object Type": dependency.iloc[5],
"Referenced Object Type": dependency.iloc[
5
],
"Done": d,
"Full Object Name": r["Full Object Name"],
"Referenced Full Object Name": dependency.iloc[
Expand All @@ -241,7 +247,9 @@ def get_model_calc_dependencies(
"Object Type": r["Object Type"],
"Referenced Object": dependency.iloc[5],
"Referenced Table": dependency.iloc[4],
"Referenced Object Type": dependency.iloc[6],
"Referenced Object Type": dependency.iloc[
6
],
"Done": d,
"Full Object Name": r["Full Object Name"],
"Referenced Full Object Name": dependency.iloc[
Expand Down
8 changes: 5 additions & 3 deletions src/sempy_labs/report/_report_bpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def run_report_bpa(
)
dfPF = rpt.list_page_filters()
# Convert back to dataframe
#if isinstance(dfPF, pd.io.formats.style.Styler):
# if isinstance(dfPF, pd.io.formats.style.Styler):
# dfPF = dfPF.data
#if isinstance(dfP, pd.io.formats.style.Styler):
# if isinstance(dfP, pd.io.formats.style.Styler):
# dfP = dfP.data

dfPF["Filter Object"] = (
Expand Down Expand Up @@ -142,7 +142,9 @@ def execute_rule(row):
df_output["Severity"] = row["Severity"]
df_output["Description"] = row["Description"]
df_output["URL"] = row["URL"]
df_output["Report URL"] = helper.get_web_url(report=report, workspace=workspace)
df_output["Report URL"] = helper.get_web_url(
report=report, workspace=workspace
)

page_mapping_dict = dfP.set_index("Page Display Name")["Page URL"].to_dict()

Expand Down
39 changes: 37 additions & 2 deletions src/sempy_labs/tom/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4248,6 +4248,37 @@ def is_calculated_table(self, table_name: str):
isCalcTable = True
return isCalcTable

def update_lineage_tags(self):
"""
Adds lineage and source lineage tags for relevant semantic model objects if they do not exist.
"""

for t in self.model.Tables:
if len(t.LineageTag) == 0:
t.LineageTag = generate_guid()
if len(t.SourceLineageTag) == 0:
t.SourceLineageTag = generate_guid()
for c in self.all_columns():
if len(c.LineageTag) == 0:
c.LineageTag = generate_guid()
if len(c.SourceLineageTag) == 0:
c.SourceLineageTag = generate_guid()
for m in self.all_measures():
if len(m.LineageTag) == 0:
m.LineageTag = generate_guid()
if len(m.SourceLineageTag) == 0:
m.SourceLineageTag = generate_guid()
for h in self.all_hierarchies():
if len(h.LineageTag) == 0:
h.LineageTag = generate_guid()
if len(h.SourceLineageTag) == 0:
h.SourceLineageTag = generate_guid()
for lvl in self.all_levels():
if len(lvl.LineageTag) == 0:
lvl.LineageTag = generate_guid()
if len(h.SourceLineageTag) == 0:
h.SourceLineageTag = generate_guid()

def generate_measure_descriptions(
self,
measure_name: Optional[str | List[str]] = None,
Expand Down Expand Up @@ -4294,10 +4325,14 @@ def generate_measure_descriptions(
}
for m_name in measure_list:
expr, t_name = next(
(ms.Expression, ms.Parent.Name) for ms in self.all_measures() if ms.Name == m_name
(ms.Expression, ms.Parent.Name)
for ms in self.all_measures()
if ms.Name == m_name
)
if t_name is None:
raise ValueError(f"{icons.red_dot} The '{m_name}' measure does not exist in the '{self._dataset}' semantic model within the '{self._workspace}' workspace.")
raise ValueError(
f"{icons.red_dot} The '{m_name}' measure does not exist in the '{self._dataset}' semantic model within the '{self._workspace}' workspace."
)

new_item = {
"urn": m_name,
Expand Down

0 comments on commit 0edf9b3

Please sign in to comment.