Skip to content

Commit

Permalink
reverted back to spark
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kovalsky committed Oct 2, 2024
1 parent 852b3e1 commit e0d5812
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Semantic Link Labs

[![PyPI version](https://badge.fury.io/py/semantic-link-labs.svg)](https://badge.fury.io/py/semantic-link-labs)
[![Read The Docs](https://readthedocs.org/projects/semantic-link-labs/badge/?version=0.8.1&style=flat)](https://readthedocs.org/projects/semantic-link-labs/)
[![Read The Docs](https://readthedocs.org/projects/semantic-link-labs/badge/?version=0.8.2&style=flat)](https://readthedocs.org/projects/semantic-link-labs/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Downloads](https://static.pepy.tech/badge/semantic-link-labs)](https://pepy.tech/project/semantic-link-labs)

Expand Down Expand Up @@ -77,6 +77,7 @@ An even better way to ensure the semantic-link-labs library is available in your
2. Select your newly created environment within the 'Environment' drop down in the navigation bar at the top of the notebook

## Version History
* [0.8.2](https://github.com/microsoft/semantic-link-labs/releases/tag/0.8.2) (October 2, 2024)
* [0.8.1](https://github.com/microsoft/semantic-link-labs/releases/tag/0.8.1) (October 2, 2024)
* [0.8.0](https://github.com/microsoft/semantic-link-labs/releases/tag/0.8.0) (September 25, 2024)
* [0.7.4](https://github.com/microsoft/semantic-link-labs/releases/tag/0.7.4) (September 16, 2024)
Expand Down
3 changes: 1 addition & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ IPython
polib
powerbiclient
azure.mgmt.resource
jsonpath_ng
deltalake
jsonpath_ng
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
project = 'semantic-link-labs'
copyright = '2024, Microsoft and community'
author = 'Microsoft and community'
release = '0.8.1'
release = '0.8.2'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name="semantic-link-labs"
authors = [
{ name = "Microsoft Corporation" },
]
version="0.8.1"
version="0.8.2"
description="Semantic Link Labs for Microsoft Fabric"
readme="README.md"
requires-python=">=3.10,<3.12"
Expand All @@ -29,7 +29,6 @@ dependencies = [
"polib",
"azure.mgmt.resource",
"jsonpath_ng",
"deltalake",
]

[tool.setuptools.packages.find]
Expand All @@ -47,7 +46,7 @@ test = [
Repository = "https://github.com/microsoft/semantic-link-labs.git"

[[tool.mypy.overrides]]
module = "sempy.*,Microsoft.*,System.*,anytree.*,powerbiclient.*,synapse.ml.services.*,polib.*,azure.mgmt.resource.*,jsonpath_ng.*,deltalake.*"
module = "sempy.*,Microsoft.*,System.*,anytree.*,powerbiclient.*,synapse.ml.services.*,polib.*,azure.mgmt.resource.*,jsonpath_ng.*"
ignore_missing_imports = true

[tool.flake8]
Expand Down
13 changes: 7 additions & 6 deletions src/sempy_labs/_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,12 +1132,13 @@ def generate_guid():
return str(uuid.uuid4())


def get_max_run_id(table_name: str) -> int:
def get_max_run_id(lakehouse: str, table_name: str) -> int:

import deltalake
table_path = f"/lakehouse/default/Tables/{table_name}/"
delta_table = deltalake.DeltaTable(table_path)
data = delta_table.to_pandas()
max_run_id = data["RunId"].max()
from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()
query = f"SELECT MAX(RunId) FROM {lakehouse}.{table_name}"
dfSpark = spark.sql(query)
max_run_id = dfSpark.collect()[0][0]

return max_run_id
4 changes: 3 additions & 1 deletion src/sempy_labs/_model_bpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ def translate_using_spark(rule_file):
if len(lakeT_filt) == 0:
runId = 1
else:
max_run_id = get_max_run_id(table_name=delta_table_name)
max_run_id = get_max_run_id(
lakehouse=lakehouse, table_name=delta_table_name
)
runId = max_run_id + 1

now = datetime.datetime.now()
Expand Down
2 changes: 1 addition & 1 deletion src/sempy_labs/_model_bpa_bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def run_model_bpa_bulk(
if len(lakeT_filt) == 0:
runId = 1
else:
max_run_id = get_max_run_id(table_name=output_table)
max_run_id = get_max_run_id(lakehouse=lakehouse, table_name=output_table)
runId = max_run_id + 1

if isinstance(workspace, str):
Expand Down
2 changes: 1 addition & 1 deletion src/sempy_labs/_vertipaq.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def vertipaq_analyzer(
if len(lakeT_filt) == 0:
runId = 1
else:
max_run_id = get_max_run_id(table_name=lakeTName)
max_run_id = get_max_run_id(lakehouse=lakehouse, table_name=lakeTName)
runId = max_run_id + 1

dfMap = {
Expand Down

0 comments on commit e0d5812

Please sign in to comment.