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

MAINT Update dependency versions #98

Merged
merged 10 commits into from
Jun 24, 2019

Conversation

stephen-hoover
Copy link
Contributor

@stephen-hoover stephen-hoover commented Jun 21, 2019

This PR increases the tensorflow version requirement to addresses the following security vulnerabilities in tensorflow: CVE-2018-7576, CVE-2018-7575, CVE-2019-9635, CVE-2018-7577, CVE-2018-10055, CVE-2018-7574. They are of severity: 1x CRITICAL, 3x HIGH, 2x MEDIUM. (From PR #97 .) Aside from increasing the required tensorflow version and adding Python 3.7 testing, the rest of this PR is all modifications to the testing code to get tests to pass. Failures seem to be due to changes in scikit-learn, scipy, and flake8.

Stephen Hoover added 7 commits June 21, 2019 13:55
The `logsumexp` function has moved in newer versions of `scipy`.
Addresses the following vulnerabilities in tensorflow: CVE-2018-7576, CVE-2018-7575, CVE-2019-9635, CVE-2018-7577, CVE-2018-10055, CVE-2018-7574. They are of severity: 1x CRITICAL, 3x HIGH, 2x MEDIUM.
The `scikit-learn` `check_estimator` was failing on a prediction check. Adjusting the number of epochs down seems to help.
Pass `flake8`; the method body was over-indented.
When installing from PyPI, pip will use the `install_requires` in `setup.py` and not `requirements.txt`. We should test with that. Also, Python 3.7.
Scikit-learn checks that model outputs are good; the model needs enough capacity and training time to properly hit the targets.
This is passing locally but still failing on Travis. (Why? It doesn't seem like this check should be failing.) Adjust parameters back to defaults, which also pass locally. Stop fixing `random_state`; the scikit-learn tests do that for us.
In `tensorflow` v1.14 and Python v3.7, one of `tensorflow`'s modules has a `0` in the `__warningregistry__` attribute. Scikit-learn's `check_estimator` attempts to `clear` this attribute, assuming that it's a dictionary. Patch in an empty dictionary so that the estimator checks complete successfully.
# with a `0` in the __warningregistry__. Scikit-learn tries to clear
# this dictionary in its tests.
name = 'tensorboard.compat.tensorflow_stub.pywrap_tensorflow'
with mock.patch.object(sys.modules[name], '__warningregistry__', {}):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not always mock this? Also, what's the error without this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would need to add the mock backport as a dev dependency for Python 2 if I wanted to always mock it. Since it's not necessary, I wanted to avoid the extra dependency. I could patch only if we have mock, but I preferred to make it clear that the problem is very version-limited.

The error from each test_check_estimator function is

___________________________________________________________________________ test_check_estimator ___________________________________________________________________________

    def test_check_estimator():
        """Check adherence to Estimator API."""
>       check_estimator(MLPRegressorFewerParams)

muffnn/mlp/tests/test_mlp_regressor.py:71:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../anaconda3/envs/muffnn-dev/lib/python3.7/site-packages/sklearn/utils/estimator_checks.py:293: in check_estimator
    check_parameters_default_constructible(name, Estimator)
../../anaconda3/envs/muffnn-dev/lib/python3.7/site-packages/sklearn/utils/estimator_checks.py:2146: in check_parameters_default_constructible
    with ignore_warnings(category=(DeprecationWarning, FutureWarning)):
../../anaconda3/envs/muffnn-dev/lib/python3.7/site-packages/sklearn/utils/testing.py:375: in __enter__
    clean_warning_registry()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def clean_warning_registry():
        """Clean Python warning registry for easier testing of warning messages.

        We may not need to do this any more when getting rid of Python 2, not
        entirely sure. See https://bugs.python.org/issue4180 and
        https://bugs.python.org/issue21724 for more details.

        """
        reg = "__warningregistry__"
        for mod_name, mod in list(sys.modules.items()):
            if hasattr(mod, reg):
>               getattr(mod, reg).clear()
E               AttributeError: 'int' object has no attribute 'clear'

../../anaconda3/envs/muffnn-dev/lib/python3.7/site-packages/sklearn/utils/testing.py:766: AttributeError

The clean_warning_registry function is part of scikit-learn's tests.

@@ -2,5 +2,5 @@ numpy~=1.14
scipy~=1.0
scikit-learn~=0.19
six~=1.10
tensorflow~=1.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this lead to the latest 1.x being installed already?

would tensorflow~=1.12.1 or tensorflow>=1.12.1,<=2.0.0 or something be better, to avoid potential incompatibilities?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in practice we were using it with a newer version of tensorflow than this. The requirement change is to ensure that installations of muffnn avoid some security vulnerabilities in tensorflow.

I updated the requirements to require <2. In practice, I think we'll become incompatible before that, but I'm sure we would be incompatible in v2.

Stephen Hoover added 2 commits June 24, 2019 12:27
We're very unlikely to be compatible with any v2 of tensorflow.
Copy link
Contributor

@mheilman mheilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@stephen-hoover stephen-hoover merged commit bb1e3ec into civisanalytics:master Jun 24, 2019
@stephen-hoover stephen-hoover deleted the update-version branch June 24, 2019 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants