Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Rename ge_cloud_id to id #9529

Merged
merged 11 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ To learn more about Checkpoints, see [Checkpoint](/reference/learn/terms/checkpo
"name": checkpoint_name,
"validations": [{
"expectation_suite_name": expectation_suite.expectation_suite_name,
"expectation_suite_ge_cloud_id": expectation_suite.ge_cloud_id,
"expectation_suite_id": expectation_suite.id,
"batch_request": {
"datasource_name": "<data_source_name>",
"data_asset_name": "<data_asset_name>",
Expand Down
16 changes: 8 additions & 8 deletions great_expectations/checkpoint/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,19 +947,19 @@ def _basic_run(
)
)

checkpoint_ge_cloud_id = None
checkpoint_id = None
if self._using_cloud_context and checkpoint_identifier:
checkpoint_ge_cloud_id = checkpoint_identifier.id
checkpoint_id = checkpoint_identifier.id

expectation_suite_ge_cloud_id = None
expectation_suite_id = None
if self._using_cloud_context and expectation_suite_identifier:
expectation_suite_ge_cloud_id = expectation_suite_identifier.id
expectation_suite_id = expectation_suite_identifier.id

return self.target_store.set(
validation_result_suite_identifier,
validation_result_suite,
checkpoint_id=checkpoint_ge_cloud_id,
expectation_suite_id=expectation_suite_ge_cloud_id,
checkpoint_id=checkpoint_id,
expectation_suite_id=expectation_suite_id,
)

def _run_cloud_post_process_resource_ref(
Expand All @@ -970,9 +970,9 @@ def _run_cloud_post_process_resource_ref(
],
):
store_set_return_value: GXCloudResourceRef
new_ge_cloud_id = gx_cloud_resource_ref.id
new_id = gx_cloud_resource_ref.id
# ValidationResultIdentifier has no `.id`
validation_result_suite_identifier.id = new_ge_cloud_id # type: ignore[union-attr]
validation_result_suite_identifier.id = new_id # type: ignore[union-attr]
return gx_cloud_resource_ref


Expand Down
61 changes: 21 additions & 40 deletions great_expectations/checkpoint/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import great_expectations.exceptions as gx_exceptions
from great_expectations._docs_decorators import (
deprecated_argument,
new_argument,
public_api,
)
from great_expectations.checkpoint.configurator import (
Expand Down Expand Up @@ -111,11 +109,6 @@ def __init__(
self._validator: Validator | None = None

@public_api
@new_argument(
argument_name="expectation_suite_ge_cloud_id",
version="0.13.33",
message="Used in cloud deployments.",
)
def run( # noqa: C901, PLR0913, PLR0915
self,
expectation_suite_name: str | None = None,
Expand All @@ -129,7 +122,7 @@ def run( # noqa: C901, PLR0913, PLR0915
run_name: str | None = None,
run_time: datetime.datetime | None = None,
result_format: str | dict | None = None,
expectation_suite_ge_cloud_id: str | None = None,
expectation_suite_id: str | None = None,
) -> CheckpointResult:
"""Validate against current Checkpoint.

Expand All @@ -148,7 +141,7 @@ def run( # noqa: C901, PLR0913, PLR0915
run_name: The run_name for the validation; if None, a default value will be used.
run_time: The date/time of the run.
result_format: One of several supported formatting directives for expectation validation results
expectation_suite_ge_cloud_id: Great Expectations Cloud id for the expectation suite
expectation_suite_id: Great Expectations Cloud id for the expectation suite

Raises:
InvalidCheckpointConfigError: If `run_id` is provided with `run_name` or `run_time`.
Expand Down Expand Up @@ -222,7 +215,7 @@ def run( # noqa: C901, PLR0913, PLR0915
"evaluation_parameters": evaluation_parameters or {},
"runtime_configuration": runtime_configuration or {},
"validations": validations or [],
"expectation_suite_ge_cloud_id": expectation_suite_ge_cloud_id,
"expectation_suite_id": expectation_suite_id,
}

substituted_runtime_config: dict = self.get_substituted_config(
Expand Down Expand Up @@ -292,7 +285,7 @@ def run( # noqa: C901, PLR0913, PLR0915
validation_result = run_result.get("validation_result") # type: ignore[assignment] # could be dict
if validation_result:
meta = validation_result.meta # type: ignore[assignment] # could be dict
id = self.ge_cloud_id
id = self.id
meta["checkpoint_id"] = id
# TODO: We only currently support 1 validation_result_url per checkpoint and use the first one we
# encounter. Since checkpoints can have more than 1 validation result, we will need to update
Expand Down Expand Up @@ -384,8 +377,8 @@ def _run_validation( # noqa: PLR0913
expectation_suite_name: str | None = substituted_validation_dict.get(
"expectation_suite_name"
)
expectation_suite_ge_cloud_id: str | None = substituted_validation_dict.get(
"expectation_suite_ge_cloud_id"
expectation_suite_id: str | None = substituted_validation_dict.get(
"expectation_suite_id"
)
include_rendered_content: bool | None = substituted_validation_dict.get(
"include_rendered_content"
Expand All @@ -400,8 +393,8 @@ def _run_validation( # noqa: PLR0913
expectation_suite_name=expectation_suite_name
if not self._using_cloud_context
else None,
expectation_suite_ge_cloud_id=(
expectation_suite_ge_cloud_id if self._using_cloud_context else None
expectation_suite_id=(
expectation_suite_id if self._using_cloud_context else None
),
include_rendered_content=include_rendered_content,
)
Expand Down Expand Up @@ -435,7 +428,7 @@ def _run_validation( # noqa: PLR0913
if self._using_cloud_context:
checkpoint_identifier = GXCloudIdentifier(
resource_type=GXCloudRESTResource.CHECKPOINT,
id=self.ge_cloud_id,
id=self.id,
)

operator_run_kwargs = {}
Expand Down Expand Up @@ -494,9 +487,9 @@ def validations(
return []

@property
def ge_cloud_id(self) -> str | None:
def id(self) -> str | None:
try:
return self.config.ge_cloud_id
return self.config.id
except AttributeError:
return None

Expand All @@ -520,16 +513,6 @@ def __repr__(self) -> str:


@public_api
@deprecated_argument(argument_name="validation_operator_name", version="0.14.0")
@deprecated_argument(argument_name="batches", version="0.14.0")
@new_argument(
argument_name="ge_cloud_id", version="0.13.33", message="Used in cloud deployments."
)
@new_argument(
argument_name="expectation_suite_ge_cloud_id",
version="0.13.33",
message="Used in cloud deployments.",
)
class Checkpoint(BaseCheckpoint):
"""A checkpoint is the primary means for validating data in a production deployment of Great Expectations.

Expand All @@ -550,10 +533,8 @@ class Checkpoint(BaseCheckpoint):
runtime_configuration: Runtime configuration to pass into the validator's runtime configuration
(e.g. `result_format`).
validations: Validations to be executed as part of checkpoint.
validation_operator_name: List of validation Operators configured by the Checkpoint.
batches: List of Batches for validation by Checkpoint.
ge_cloud_id: Great Expectations Cloud id for this Checkpoint.
expectation_suite_ge_cloud_id: Great Expectations Cloud id associated with Expectation Suite.
id: Great Expectations Cloud id for this Checkpoint.
expectation_suite_id: Great Expectations Cloud id associated with Expectation Suite.
default_validation_id: Default value used by Checkpoint if no Validations are configured.

Raises:
Expand Down Expand Up @@ -592,8 +573,8 @@ def __init__( # noqa: PLR0913
evaluation_parameters: dict | None = None,
runtime_configuration: dict | None = None,
validations: list[dict] | list[CheckpointValidationConfig] | None = None,
ge_cloud_id: str | None = None,
expectation_suite_ge_cloud_id: str | None = None,
id: str | None = None,
expectation_suite_id: str | None = None,
default_validation_id: str | None = None,
) -> None:
validations = convert_validations_list_to_checkpoint_validation_configs(
Expand Down Expand Up @@ -646,8 +627,8 @@ def __init__( # noqa: PLR0913
evaluation_parameters=evaluation_parameters,
runtime_configuration=runtime_configuration,
validations=validations,
ge_cloud_id=ge_cloud_id,
expectation_suite_ge_cloud_id=expectation_suite_ge_cloud_id,
id=id,
expectation_suite_id=expectation_suite_id,
default_validation_id=default_validation_id,
)
super().__init__(
Expand All @@ -673,8 +654,8 @@ def construct_from_config_args( # noqa: PLR0913
validations: Optional[
Union[list[dict], list[CheckpointValidationConfig]]
] = None,
ge_cloud_id: Optional[str] = None,
expectation_suite_ge_cloud_id: Optional[str] = None,
id: Optional[str] = None,
expectation_suite_id: Optional[str] = None,
default_validation_id: Optional[str] = None,
validator: Validator | None = None,
) -> Checkpoint:
Expand Down Expand Up @@ -713,8 +694,8 @@ def construct_from_config_args( # noqa: PLR0913
"evaluation_parameters": evaluation_parameters,
"runtime_configuration": runtime_configuration,
"validations": validations,
"ge_cloud_id": ge_cloud_id,
"expectation_suite_ge_cloud_id": expectation_suite_ge_cloud_id,
"id": id,
"expectation_suite_id": expectation_suite_id,
"default_validation_id": default_validation_id,
}

Expand Down
12 changes: 4 additions & 8 deletions great_expectations/checkpoint/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,8 @@ def get_substituted_validation_dict(
),
"expectation_suite_name": validation_dict.get("expectation_suite_name")
or substituted_runtime_config.get("expectation_suite_name"),
"expectation_suite_ge_cloud_id": validation_dict.get(
"expectation_suite_ge_cloud_id"
)
or substituted_runtime_config.get("expectation_suite_ge_cloud_id"),
"expectation_suite_id": validation_dict.get("expectation_suite_id")
or substituted_runtime_config.get("expectation_suite_id"),
"action_list": get_updated_action_list(
base_action_list=substituted_runtime_config.get("action_list", []),
other_action_list=validation_dict.get("action_list", {}),
Expand Down Expand Up @@ -282,10 +280,8 @@ def substitute_runtime_config(source_config: dict, runtime_kwargs: dict) -> dict
# replace
if runtime_kwargs.get("expectation_suite_name") is not None:
dest_config["expectation_suite_name"] = runtime_kwargs["expectation_suite_name"]
if runtime_kwargs.get("expectation_suite_ge_cloud_id") is not None:
dest_config["expectation_suite_ge_cloud_id"] = runtime_kwargs[
"expectation_suite_ge_cloud_id"
]
if runtime_kwargs.get("expectation_suite_id") is not None:
dest_config["expectation_suite_id"] = runtime_kwargs["expectation_suite_id"]
# update
if runtime_kwargs.get("batch_request") is not None:
batch_request = dest_config.get("batch_request") or {}
Expand Down