-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add integration tests for end to end flow for data checks --> data check actions #2883
Merged
Merged
Changes from 19 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
8ac51dc
init
angela97lin 887d8b7
add empty
angela97lin 2a3e898
in the middle of return row removal test
angela97lin 7fba44d
add integration test command and workflow
angela97lin fb2c330
ignore integration in other core tests
angela97lin 2281c68
rename and call integration test command
angela97lin deb121d
Merge branch 'main' into 2815_dc_integration
angela97lin 00fc198
merging
angela97lin 0d40228
Merge branch 'main' into 2815_dc_integration
angela97lin 14d8af2
release notes
angela97lin 0e799c1
Merge branch 'main' into 2815_dc_integration
angela97lin c11f33e
fix integration matrix
angela97lin 8602e35
Merge branch '2815_dc_integration' of github.com:alteryx/evalml into …
angela97lin fe1cc9e
clean up row removal test and add new method to convert from dict bac…
angela97lin 38ac09e
add tests
angela97lin 650f7ab
add drop rows test
angela97lin ff475f3
Merge branch 'main' into 2815_dc_integration
angela97lin b3b6e4b
linting
angela97lin 259c2bf
cleaning up yaml
angela97lin a45edde
rename integration tests folder
angela97lin 4ffb6f9
add empty init file
angela97lin c14ca5e
try to add coverage
angela97lin c491e7c
remove entirely
angela97lin c7483f7
attempt to remove
angela97lin c43327c
move back
angela97lin 8c4bd98
fix yaml
angela97lin 434b08a
add coverage to integration yaml
angela97lin d063aa4
makefile
angela97lin 6e88b18
try add erase coverage block
angela97lin 515765e
merging main
angela97lin d463c6f
clean up merging and outdated code
angela97lin 9001544
fix tests from merging
angela97lin 0fe1b8c
Merge branch 'main' into 2815_dc_integration
angela97lin e49756c
remove unnecessary assignment from tests:
angela97lin e5f9efc
Merge branch 'main' into 2815_dc_integration
angela97lin 55a7474
Merge branch 'main' into 2815_dc_integration
angela97lin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Integration tests, linux | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
integration_tests: | ||
name: ${{ matrix.python_version }} unit ${{matrix.command}} tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- python_version: "3.8" | ||
core_dependencies: false | ||
command: 'git-test-integration' | ||
|
||
steps: | ||
- name: Set up Python ${{ matrix.python_version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python_version }} | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
fetch-depth: 2 | ||
- name: Update apt and install Graphviz | ||
run: sudo apt update && sudo apt install -y graphviz | ||
name: Installing Dependencies | ||
run: | | ||
pip install virtualenv | ||
virtualenv test_python -q | ||
source test_python/bin/activate | ||
make installdeps | ||
make installdeps-test | ||
pip freeze | ||
- name: Run integration tests | ||
run: | | ||
source test_python/bin/activate | ||
make ${{matrix.command}} | ||
- name: Upload pytest duration artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: pytest-duration-report | ||
path: test-reports/${{matrix.command}}-junit.xml |
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
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
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 |
---|---|---|
|
@@ -381,16 +381,16 @@ def _make_component_list_from_actions(actions): | |
cols_to_drop = [] | ||
for action in actions: | ||
if action.action_code == DataCheckActionCode.DROP_COL: | ||
cols_to_drop.append(action.metadata["column"]) | ||
cols_to_drop.extend(action.metadata["columns"]) | ||
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. Cleanup after the standardization in #2869 |
||
elif action.action_code == DataCheckActionCode.IMPUTE_COL: | ||
metadata = action.metadata | ||
if metadata["is_target"]: | ||
components.append( | ||
TargetImputer(impute_strategy=metadata["impute_strategy"]) | ||
) | ||
elif action.action_code == DataCheckActionCode.DROP_ROWS: | ||
indices = action.metadata["indices"] | ||
components.append(DropRowsTransformer(indices_to_drop=indices)) | ||
rows = action.metadata["rows"] | ||
components.append(DropRowsTransformer(indices_to_drop=rows)) | ||
if cols_to_drop: | ||
components.append(DropColumns(columns=cols_to_drop)) | ||
return components | ||
|
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
132 changes: 132 additions & 0 deletions
132
evalml/tests/integration/test_data_checks_and_actions_integration.py
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 |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import woodwork as ww | ||
from pandas.testing import assert_frame_equal, assert_series_equal | ||
|
||
from evalml.automl import get_default_primary_search_objective | ||
from evalml.data_checks import ( | ||
DataCheckAction, | ||
DefaultDataChecks, | ||
OutliersDataCheck, | ||
) | ||
from evalml.data_checks.highly_null_data_check import HighlyNullDataCheck | ||
from evalml.data_checks.invalid_targets_data_check import ( | ||
InvalidTargetDataCheck, | ||
) | ||
from evalml.pipelines.components import ( | ||
DropColumns, | ||
DropRowsTransformer, | ||
TargetImputer, | ||
) | ||
from evalml.pipelines.utils import _make_component_list_from_actions | ||
|
||
|
||
def test_data_checks_with_healthy_data(X_y_binary): | ||
# Checks do not return any error. | ||
X, y = X_y_binary | ||
data_check = DefaultDataChecks( | ||
"binary", get_default_primary_search_objective("binary") | ||
) | ||
data_check_output = data_check.validate(X, y) | ||
assert _make_component_list_from_actions(data_check_output["actions"]) == [] | ||
|
||
|
||
def test_data_checks_suggests_drop_cols(): | ||
X = pd.DataFrame( | ||
{ | ||
"lots_of_null": [None, 2, None, 3, 5], | ||
"all_null": [None, None, None, None, None], | ||
"no_null": [1, 2, 3, 4, 5], | ||
} | ||
) | ||
y = pd.Series([1, 0, 0, 1, 1]) | ||
data_check = HighlyNullDataCheck() | ||
data_checks_output = data_check.validate(X, y) | ||
|
||
actions = [ | ||
DataCheckAction.convert_dict_to_action(action) | ||
for action in data_checks_output["actions"] | ||
] | ||
|
||
action_components = _make_component_list_from_actions(actions) | ||
assert action_components == [DropColumns(columns=["all_null"])] | ||
|
||
X_t = pd.DataFrame( | ||
{ | ||
"lots_of_null": [None, 2, None, 3, 5], | ||
"all_null": [None, None, None, None, None], | ||
"no_null": [1, 2, 3, 4, 5], | ||
} | ||
) | ||
X_expected = pd.DataFrame( | ||
{ | ||
"lots_of_null": [None, 2, None, 3, 5], | ||
"no_null": [1, 2, 3, 4, 5], | ||
} | ||
) | ||
for component in action_components: | ||
X_t = component.fit_transform(X_t) | ||
assert_frame_equal(X_expected, X_t) | ||
|
||
|
||
def test_data_checks_impute_cols(): | ||
y = ww.init_series(pd.Series([0, 1, 1, None, None])) | ||
|
||
data_check = InvalidTargetDataCheck("binary", "Log Loss Binary") | ||
data_checks_output = data_check.validate(None, y) | ||
|
||
actions = [ | ||
DataCheckAction.convert_dict_to_action(action) | ||
for action in data_checks_output["actions"] | ||
] | ||
|
||
action_components = _make_component_list_from_actions(actions) | ||
assert action_components == [ | ||
TargetImputer(impute_strategy="most_frequent", fill_value=None) | ||
] | ||
|
||
y_expected = ww.init_series(pd.Series([0, 1, 1, 1, 1]), logical_type="double") | ||
y_t = ww.init_series(pd.Series([0, 1, 1, None, None])) | ||
for component in action_components: | ||
_, y_t = component.fit_transform(None, y_t) | ||
assert_series_equal(y_expected, y_t) | ||
|
||
|
||
def test_data_checks_suggests_drop_rows(): | ||
a = np.arange(10) * 0.01 | ||
data = np.tile(a, (100, 10)) | ||
|
||
X = pd.DataFrame(data=data) | ||
X.iloc[0, 3] = 1000 | ||
X.iloc[3, 25] = 1000 | ||
X.iloc[5, 55] = 10000 | ||
X.iloc[10, 72] = -1000 | ||
X.iloc[:, 90] = "string_values" | ||
y = pd.Series(np.tile([0, 1], 50)) | ||
|
||
outliers_check = OutliersDataCheck() | ||
data_checks_output = outliers_check.validate(X) | ||
|
||
actions = [ | ||
DataCheckAction.convert_dict_to_action(action) | ||
for action in data_checks_output["actions"] | ||
] | ||
action_components = _make_component_list_from_actions(actions) | ||
assert action_components == [DropRowsTransformer()] | ||
|
||
X_t = pd.DataFrame(data=data) | ||
X_t.iloc[0, 3] = 1000 | ||
X_t.iloc[3, 25] = 1000 | ||
X_t.iloc[5, 55] = 10000 | ||
X_t.iloc[10, 72] = -1000 | ||
X_t.iloc[:, 90] = "string_values" | ||
X_t.ww.init() | ||
y_t = pd.Series(np.tile([0, 1], 50)) | ||
|
||
X_expected = X.drop([0, 3, 5, 10]) | ||
X_expected.ww.init() | ||
y_expected = y.drop([0, 3, 5, 10]) | ||
for component in action_components: | ||
X_t, y_t = component.fit_transform(X_t, y_t) | ||
assert_frame_equal(X_expected, X_t) | ||
assert_series_equal(y_expected, y_t) |
Oops, something went wrong.
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.
I think it's fine to run just one python version for now, but curious if there are other opinions!