Skip to content

Commit

Permalink
GX1.0 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurKordes authored and ArthurKordes committed Sep 19, 2024
1 parent b7da434 commit b160fd4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies = [
"pandas==2.1.4",
"pyspark==3.5.2",
"pyhumps==3.8.0",
"pyyaml==6.0.2",
]


Expand Down
25 changes: 17 additions & 8 deletions src/dq_suite/common.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from dataclasses import dataclass
from typing import Any, Dict, List, Literal
import yaml

from great_expectations import ExpectationSuite, get_context
from great_expectations.data_context import AbstractDataContext
from great_expectations.data_context import (
AbstractDataContext,
EphemeralDataContext,
)
from great_expectations.data_context.types.base import (
DataContextConfig,
InMemoryStoreBackendDefaults,
)
from great_expectations.exceptions import DataContextError
from pyspark.sql import DataFrame, SparkSession
from pyspark.sql.functions import col
Expand Down Expand Up @@ -207,10 +215,13 @@ def merge_df_with_unity_table(
.execute()


def get_data_context(
data_context_root_dir: str = "/dbfs/great_expectations/",
) -> AbstractDataContext: # pragma: no cover - part of GX
return get_context(context_root_dir=data_context_root_dir)
def get_data_context() -> AbstractDataContext: # pragma: no cover - part of GX
return get_context(
project_config=DataContextConfig(
store_backend_defaults=InMemoryStoreBackendDefaults(),
analytics_enabled=False
)
)


@dataclass()
Expand Down Expand Up @@ -285,9 +296,7 @@ def initialise_or_update_attributes(self): # pragma: no cover - complex
)

def _set_data_context(self): # pragma: no cover - uses part of GX
self.data_context = get_data_context(
data_context_root_dir=self.data_context_root_dir
)
self.data_context = get_data_context()

def _set_expectation_suite_name(self):
self.expectation_suite_name = f"{self.check_name}_expectation_suite"
Expand Down
4 changes: 2 additions & 2 deletions src/dq_suite/output_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def construct_regel_id(


def create_parameter_list_from_results(result: dict) -> list[dict]:
parameters = result["expectation_config"]["kwargs"]
parameters = result["kwargs"]
parameters.pop("batch_id", None)
return [parameters]

Expand Down Expand Up @@ -88,7 +88,7 @@ def extract_dq_validatie_data(
expectation_type = expectation_result["expectation_type"]
parameter_list = create_parameter_list_from_results(result=expectation_result)
attribute = expectation_result["kwargs"].get("column")
dq_regel_id = f"{df_name}_{expectation_type}_{attribute}"

output = expectation_result["success"]
output_text = "success" if output else "failure"
extracted_data.append(
Expand Down

0 comments on commit b160fd4

Please sign in to comment.