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] Improve get validator functionality #4661
Merged
abegong
merged 14 commits into
develop
from
maintenance/improve-get-validator-functionality
Apr 6, 2022
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
93f5ff6
Make it optional to include an ExpectationSuite or parameters define …
abegong 0390b74
Enable DataContext.get_validator to accept a single batch as an input…
abegong e94e3d8
Merge branch 'develop' into maintenance/improve-get-validator-functio…
abegong 808fedc
Merge branch 'develop' into maintenance/improve-get-validator-functio…
abegong 5bc53c8
Merge branch 'develop' into maintenance/improve-get-validator-functio…
abegong c7c3ee1
Move in_memory_runtime_context to conftest.py
abegong 3a5bb87
Add batch_list to Context.get_validator
abegong 31ab354
Simplify new tests
abegong 8adb87d
Update tests/data_context/test_data_context.py
abegong df20475
Merge branch 'develop' into maintenance/improve-get-validator-functio…
abegong bb25837
lint
abegong 6ab6a3b
Merge branch 'maintenance/improve-get-validator-functionality' of git…
abegong 38938dd
Lint again
abegong 69e1fd7
Resolve warnings and errors
abegong File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1788,6 +1788,107 @@ def test_get_validator_with_attach_expectation_suite( | |
) | ||
assert my_validator.expectation_suite_name == "A_expectation_suite" | ||
|
||
def test_get_validator_without_expectation_suite( | ||
in_memory_runtime_context | ||
): | ||
context = in_memory_runtime_context | ||
|
||
batch = context.get_batch( | ||
batch_request=RuntimeBatchRequest( | ||
datasource_name="pandas_datasource", | ||
data_connector_name="runtime_data_connector", | ||
data_asset_name="my_data_asset", | ||
runtime_parameters={ | ||
"batch_data": pd.DataFrame({ | ||
"x": range(10) | ||
}) | ||
}, | ||
batch_identifiers={ | ||
"id_key_0": "id_0_value_a", | ||
"id_key_1": "id_1_value_a", | ||
}, | ||
) | ||
) | ||
|
||
my_validator = context.get_validator( | ||
batch=batch | ||
) | ||
assert type(my_validator.get_expectation_suite()) == ExpectationSuite | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick - Could we use
abegong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert my_validator.expectation_suite_name == "default" | ||
|
||
def test_get_validator_with_batch( | ||
in_memory_runtime_context | ||
): | ||
context = in_memory_runtime_context | ||
|
||
my_batch = context.get_batch( | ||
batch_request=RuntimeBatchRequest( | ||
datasource_name="pandas_datasource", | ||
data_connector_name="runtime_data_connector", | ||
data_asset_name="my_data_asset", | ||
runtime_parameters={ | ||
"batch_data": pd.DataFrame({ | ||
"x": range(10) | ||
}) | ||
}, | ||
batch_identifiers={ | ||
"id_key_0": "id_0_value_a", | ||
"id_key_1": "id_1_value_a", | ||
}, | ||
) | ||
) | ||
|
||
my_validator = context.get_validator( | ||
batch=my_batch, | ||
create_expectation_suite_with_name="A_expectation_suite", | ||
) | ||
|
||
def test_get_validator_with_batch_list( | ||
in_memory_runtime_context | ||
): | ||
context = in_memory_runtime_context | ||
|
||
my_batch_list = [ | ||
context.get_batch( | ||
batch_request=RuntimeBatchRequest( | ||
datasource_name="pandas_datasource", | ||
data_connector_name="runtime_data_connector", | ||
data_asset_name="my_data_asset", | ||
runtime_parameters={ | ||
"batch_data": pd.DataFrame({ | ||
"x": range(10) | ||
}) | ||
}, | ||
batch_identifiers={ | ||
"id_key_0": "id_0_value_a", | ||
"id_key_1": "id_1_value_a", | ||
}, | ||
) | ||
), | ||
context.get_batch( | ||
batch_request=RuntimeBatchRequest( | ||
datasource_name="pandas_datasource", | ||
data_connector_name="runtime_data_connector", | ||
data_asset_name="my_data_asset", | ||
runtime_parameters={ | ||
"batch_data": pd.DataFrame({ | ||
"y": range(10) | ||
}) | ||
}, | ||
batch_identifiers={ | ||
"id_key_0": "id_0_value_b", | ||
"id_key_1": "id_1_value_b", | ||
}, | ||
) | ||
), | ||
] | ||
|
||
my_validator = context.get_validator( | ||
batch_list=my_batch_list, | ||
create_expectation_suite_with_name="A_expectation_suite", | ||
) | ||
assert len(my_validator.batches) == 2 | ||
|
||
|
||
def test_get_batch_multiple_datasources_do_not_scan_all( | ||
data_context_with_bad_datasource, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abegong I believe that this should be
batch_list: List[Batch]
-- do you agree? At least some way to accept list ofBatch
objects, even if we must support the passing of a singleBatch
object. ThanksThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For usability sake I think it's important to take a single
Batch
as an argument.We could also add the option to pass a
batch_list
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abegong I agree -- and, if possible, would prefer for both to be supported in the same pull request. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made this change