mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-04 13:36:46 +00:00
feat(ingest/gx): support gx version 0.18.0 (#11823)
This commit is contained in:
parent
a559c7ee5f
commit
5094dabdf4
2
.github/workflows/gx-plugin.yml
vendored
2
.github/workflows/gx-plugin.yml
vendored
@ -39,6 +39,8 @@ jobs:
|
|||||||
extraPythonRequirement: "great-expectations~=0.16.0 numpy~=1.26.0"
|
extraPythonRequirement: "great-expectations~=0.16.0 numpy~=1.26.0"
|
||||||
- python-version: "3.11"
|
- python-version: "3.11"
|
||||||
extraPythonRequirement: "great-expectations~=0.17.0"
|
extraPythonRequirement: "great-expectations~=0.17.0"
|
||||||
|
- python-version: "3.11"
|
||||||
|
extraPythonRequirement: "great-expectations~=0.18.0"
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
steps:
|
steps:
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
|
@ -38,7 +38,7 @@ base_requirements = {
|
|||||||
# GE added handling for higher version of jinja2 in version 0.15.12
|
# GE added handling for higher version of jinja2 in version 0.15.12
|
||||||
# https://github.com/great-expectations/great_expectations/pull/5382/files
|
# https://github.com/great-expectations/great_expectations/pull/5382/files
|
||||||
# TODO: support GX 0.18.0
|
# TODO: support GX 0.18.0
|
||||||
"great-expectations>=0.15.12, <0.18.0",
|
"great-expectations>=0.15.12, <1.0.0",
|
||||||
# datahub does not depend on traitlets directly but great expectations does.
|
# datahub does not depend on traitlets directly but great expectations does.
|
||||||
# https://github.com/ipython/traitlets/issues/741
|
# https://github.com/ipython/traitlets/issues/741
|
||||||
"traitlets<5.2.2",
|
"traitlets<5.2.2",
|
||||||
|
@ -8,6 +8,7 @@ from decimal import Decimal
|
|||||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
import datahub.emitter.mce_builder as builder
|
import datahub.emitter.mce_builder as builder
|
||||||
|
import packaging.version
|
||||||
from datahub.cli.env_utils import get_boolean_env_variable
|
from datahub.cli.env_utils import get_boolean_env_variable
|
||||||
from datahub.emitter.mcp import MetadataChangeProposalWrapper
|
from datahub.emitter.mcp import MetadataChangeProposalWrapper
|
||||||
from datahub.emitter.rest_emitter import DatahubRestEmitter
|
from datahub.emitter.rest_emitter import DatahubRestEmitter
|
||||||
@ -59,6 +60,16 @@ from great_expectations.validator.validator import Validator
|
|||||||
from sqlalchemy.engine.base import Connection, Engine
|
from sqlalchemy.engine.base import Connection, Engine
|
||||||
from sqlalchemy.engine.url import make_url
|
from sqlalchemy.engine.url import make_url
|
||||||
|
|
||||||
|
# TODO: move this and version check used in tests to some common module
|
||||||
|
try:
|
||||||
|
from great_expectations import __version__ as GX_VERSION # type: ignore
|
||||||
|
|
||||||
|
has_name_positional_arg = packaging.version.parse(
|
||||||
|
GX_VERSION
|
||||||
|
) >= packaging.version.Version("0.18.0")
|
||||||
|
except Exception:
|
||||||
|
has_name_positional_arg = False
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from great_expectations.data_context.types.resource_identifiers import (
|
from great_expectations.data_context.types.resource_identifiers import (
|
||||||
GXCloudIdentifier,
|
GXCloudIdentifier,
|
||||||
@ -78,6 +89,8 @@ class DataHubValidationAction(ValidationAction):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
data_context: AbstractDataContext,
|
data_context: AbstractDataContext,
|
||||||
|
# this would capture `name` positional arg added in GX 0.18.0
|
||||||
|
*args: Union[str, Any],
|
||||||
server_url: str,
|
server_url: str,
|
||||||
env: str = builder.DEFAULT_ENV,
|
env: str = builder.DEFAULT_ENV,
|
||||||
platform_alias: Optional[str] = None,
|
platform_alias: Optional[str] = None,
|
||||||
@ -94,6 +107,11 @@ class DataHubValidationAction(ValidationAction):
|
|||||||
name: str = "DataHubValidationAction",
|
name: str = "DataHubValidationAction",
|
||||||
):
|
):
|
||||||
|
|
||||||
|
if has_name_positional_arg:
|
||||||
|
if len(args) >= 1 and isinstance(args[0], str):
|
||||||
|
name = args[0]
|
||||||
|
super().__init__(data_context, name)
|
||||||
|
else:
|
||||||
super().__init__(data_context)
|
super().__init__(data_context)
|
||||||
self.server_url = server_url
|
self.server_url = server_url
|
||||||
self.env = env
|
self.env = env
|
||||||
|
@ -30,7 +30,7 @@ from great_expectations.core.expectation_validation_result import (
|
|||||||
)
|
)
|
||||||
from great_expectations.core.id_dict import IDDict
|
from great_expectations.core.id_dict import IDDict
|
||||||
from great_expectations.core.run_identifier import RunIdentifier
|
from great_expectations.core.run_identifier import RunIdentifier
|
||||||
from great_expectations.data_context import DataContext, FileDataContext
|
from great_expectations.data_context import FileDataContext
|
||||||
from great_expectations.data_context.types.resource_identifiers import (
|
from great_expectations.data_context.types.resource_identifiers import (
|
||||||
ExpectationSuiteIdentifier,
|
ExpectationSuiteIdentifier,
|
||||||
ValidationResultIdentifier,
|
ValidationResultIdentifier,
|
||||||
@ -52,7 +52,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def ge_data_context(tmp_path: str) -> DataContext:
|
def ge_data_context(tmp_path: str) -> FileDataContext:
|
||||||
return FileDataContext.create(tmp_path)
|
return FileDataContext.create(tmp_path)
|
||||||
|
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ def ge_validation_result_suite_id_pandas() -> ValidationResultIdentifier:
|
|||||||
@mock.patch("datahub.emitter.rest_emitter.DatahubRestEmitter.emit_mcp", autospec=True)
|
@mock.patch("datahub.emitter.rest_emitter.DatahubRestEmitter.emit_mcp", autospec=True)
|
||||||
def test_DataHubValidationAction_sqlalchemy(
|
def test_DataHubValidationAction_sqlalchemy(
|
||||||
mock_emitter: mock.MagicMock,
|
mock_emitter: mock.MagicMock,
|
||||||
ge_data_context: DataContext,
|
ge_data_context: FileDataContext,
|
||||||
ge_validator_sqlalchemy: Validator,
|
ge_validator_sqlalchemy: Validator,
|
||||||
ge_validation_result_suite: ExpectationSuiteValidationResult,
|
ge_validation_result_suite: ExpectationSuiteValidationResult,
|
||||||
ge_validation_result_suite_id: ValidationResultIdentifier,
|
ge_validation_result_suite_id: ValidationResultIdentifier,
|
||||||
@ -337,7 +337,7 @@ def test_DataHubValidationAction_sqlalchemy(
|
|||||||
@mock.patch("datahub.emitter.rest_emitter.DatahubRestEmitter.emit_mcp", autospec=True)
|
@mock.patch("datahub.emitter.rest_emitter.DatahubRestEmitter.emit_mcp", autospec=True)
|
||||||
def test_DataHubValidationAction_pandas(
|
def test_DataHubValidationAction_pandas(
|
||||||
mock_emitter: mock.MagicMock,
|
mock_emitter: mock.MagicMock,
|
||||||
ge_data_context: DataContext,
|
ge_data_context: FileDataContext,
|
||||||
ge_validator_pandas: Validator,
|
ge_validator_pandas: Validator,
|
||||||
ge_validation_result_suite_pandas: ExpectationSuiteValidationResult,
|
ge_validation_result_suite_pandas: ExpectationSuiteValidationResult,
|
||||||
ge_validation_result_suite_id_pandas: ValidationResultIdentifier,
|
ge_validation_result_suite_id_pandas: ValidationResultIdentifier,
|
||||||
@ -399,7 +399,7 @@ def test_DataHubValidationAction_pandas(
|
|||||||
|
|
||||||
|
|
||||||
def test_DataHubValidationAction_graceful_failure(
|
def test_DataHubValidationAction_graceful_failure(
|
||||||
ge_data_context: DataContext,
|
ge_data_context: FileDataContext,
|
||||||
ge_validator_sqlalchemy: Validator,
|
ge_validator_sqlalchemy: Validator,
|
||||||
ge_validation_result_suite: ExpectationSuiteValidationResult,
|
ge_validation_result_suite: ExpectationSuiteValidationResult,
|
||||||
ge_validation_result_suite_id: ValidationResultIdentifier,
|
ge_validation_result_suite_id: ValidationResultIdentifier,
|
||||||
@ -418,7 +418,7 @@ def test_DataHubValidationAction_graceful_failure(
|
|||||||
|
|
||||||
|
|
||||||
def test_DataHubValidationAction_not_supported(
|
def test_DataHubValidationAction_not_supported(
|
||||||
ge_data_context: DataContext,
|
ge_data_context: FileDataContext,
|
||||||
ge_validator_spark: Validator,
|
ge_validator_spark: Validator,
|
||||||
ge_validation_result_suite: ExpectationSuiteValidationResult,
|
ge_validation_result_suite: ExpectationSuiteValidationResult,
|
||||||
ge_validation_result_suite_id: ValidationResultIdentifier,
|
ge_validation_result_suite_id: ValidationResultIdentifier,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user