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

[BUG] mlflow tests are failing with missing soft dependencies error #5859

Closed
yarnabrina opened this issue Jan 29, 2024 · 3 comments · Fixed by #5888
Closed

[BUG] mlflow tests are failing with missing soft dependencies error #5859

yarnabrina opened this issue Jan 29, 2024 · 3 comments · Fixed by #5888
Labels
bug Something isn't working module:tests test framework functionality - only framework, excl specific tests
Projects

Comments

@yarnabrina
Copy link
Collaborator

I was trying to address #5855, and tried to test my fix in #5858 by running the tests locally. That failed with following error:

pytest sktime/utils/tests/test_mlflow_sktime_model_export.py
...
================================= short test summary info ==================================
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_auto_arima_model_save_and_load[pickle] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_auto_arima_model_save_and_load[cloudpickle] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_auto_arima_model_pyfunc_output[pickle] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_auto_arima_model_pyfunc_output[cloudpickle] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_cnn_model_save_and_load[pickle] - ModuleNotFoundError: tensorflow is required for deep learning functionality in `sktime`...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_cnn_model_save_and_load[cloudpickle] - ModuleNotFoundError: tensorflow is required for deep learning functionality in `sktime`...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_auto_arima_model_pyfunc_with_params_output - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_auto_arima_model_pyfunc_without_params_output - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_auto_arima_model_pyfunc_without_conf_output - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_signature_and_examples_saved_correctly[True-True] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_signature_and_examples_saved_correctly[True-False] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_signature_and_examples_saved_correctly[False-True] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_signature_and_examples_saved_correctly[False-False] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_predict_var_signature_saved_correctly[True] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_predict_var_signature_saved_correctly[False] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_signature_and_example_for_pyfunc_predict[True-True] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_signature_and_example_for_pyfunc_predict[True-False] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_signature_and_example_for_pyfunc_predict[False-True] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_signature_and_example_for_pyfunc_predict[False-False] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_load_from_remote_uri_succeeds - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_log_model[pickle-True] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_log_model[pickle-False] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_log_model[cloudpickle-True] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_log_model[cloudpickle-False] - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_log_model_no_registered_model_name - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_pyfunc_raises_invalid_attribute_type - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_pyfunc_raises_invalid_dict_key - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_pyfunc_raises_invalid_dict_value_type - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_pyfunc_raises_invalid_dict_value - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_pyfunc_predict_proba_raises_invalid_attribute_type - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_pyfunc_predict_proba_raises_invalid_dict_value - ModuleNotFoundError: AutoARIMA requires package 'pmdarima' to be present in the python ...
==================== 1 passed, 1 xfailed, 1 warning, 31 errors in 6.43s ====================

My expectation was that _check_soft_dependencies will be used throughout to ensure relevant packages are available before testing, and skip otherwise.

FYI @achieveordie @benjaminbluhm as authors of the file.

@yarnabrina yarnabrina added the bug Something isn't working label Jan 29, 2024
@fkiraly fkiraly added the module:tests test framework functionality - only framework, excl specific tests label Jan 29, 2024
@fkiraly
Copy link
Collaborator

fkiraly commented Jan 29, 2024

I thik the reason is that the import statements confuse statsmodels and pmdarima. The former is a dep of the latter, and the strictly weaker statement is the skip condition.

I further assume that this was not noticed by too many people (probably a low number and they did not report), because typically forecasting users have either both of, or none of statsmodels and pmdarima installed in their environment - and so do the sktime test environments (they have both or none).

Specifically, I hypothesize that the failure condition is having statsmodels installed but not pmdarima.

@yarnabrina
Copy link
Collaborator Author

Just noting, in case you missed, there's two tensorflow failures as well.

ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_cnn_model_save_and_load[pickle] - ModuleNotFoundError: tensorflow is required for deep learning functionality in sktime...
ERROR sktime/utils/tests/test_mlflow_sktime_model_export.py::test_cnn_model_save_and_load[cloudpickle] - ModuleNotFoundError: tensorflow is required for deep learning functionality in sktime...

I'm quite unfamiliar with this particular module, I never used the custom mlflow flavour for sktime (only used standard mlflow-skinny to track final metrics and log binary model file). But my opinion is we can add the pytest.skip calls to all test functions with check soft dependencies as it happens in most other test files.

@achieveordie
Copy link
Collaborator

Let me take a look at this and get back to you.

@fkiraly fkiraly added this to Needs triage & validation in Bugfixing via automation Jan 30, 2024
yarnabrina pushed a commit that referenced this issue Feb 4, 2024
<!--
Welcome to sktime, and thanks for contributing!
Please have a look at our contribution guide:
https://www.sktime.net/en/latest/get_involved/contributing.html
-->

#### Reference Issues/PRs
<!--
Example: Fixes #1234. See also #3456.

Please use keywords (e.g., Fixes) to create link to the issues or pull
requests
you resolved, so that they will automatically be closed when your pull
request
is merged. See
https://github.com/blog/1506-closing-issues-via-pull-requests.
If no issue exists, you can open one here:
https://github.com/sktime/sktime/issues
-->
Fixes #5859

#### What does this implement/fix? Explain your changes.
<!--
A clear and concise description of what you have implemented.
-->
`mlflow` tests were missing the skip markers despite using estimators
like `AutoARIMA` and `CNNClassifier` that have soft dependencies. I've
added `pytest.mark.skipif` decorators on top of each fixture/test that
make use of either of these estimators.

#### Does your contribution introduce a new dependency? If yes, which
one?

<!--
Only relevant if you changed pyproject.toml.
We try to minimize dependencies in the core dependency set. There
are also further specific instructions to follow for soft dependencies.
See here for handling dependencies in sktime:
https://www.sktime.net/en/latest/developer_guide/dependencies.html
-->
None

#### What should a reviewer concentrate their feedback on?

<!-- This section is particularly useful if you have a pull request that
is still in development. You can guide the reviews to focus on the parts
that are ready for their comments. We suggest using bullets (indicated
by * or -) and filled checkboxes [x] here -->
I'm not particularly fond of cases where I find myself copy-pasting any
amount of code. I can appreciate the modularity such unit tests provide
but I was wondering if we could instead use classes (one for mlflow-only
test, mlflow-arima tests and mlflow-tensorflow tests).

#### Did you add any tests for the change?

<!-- This section is useful if you have added a test in addition to the
existing ones. This will ensure that further changes to these files
won't introduce the same kind of bug. It is considered good practice to
add tests with newly added code to enforce the fact that the code
actually works. This will reduce the chance of introducing logical bugs.
-->

#### Any other comments?
<!--
We value all user contributions, no matter how small or complex they
are. If you have any questions, feel free to post
in the dev-chat channel on the sktime discord
https://discord.com/invite/54ACzaFsn7. If we are slow to review (>3
working days), likewise feel free to ping us on discord. Thank you for
your understanding during the review process.
-->

#### PR checklist
<!--
Please go through the checklist below. Please feel free to remove points
if they are not applicable.
-->

##### For all contributions
- [ ] I've added myself to the [list of
contributors](https://github.com/sktime/sktime/blob/main/CONTRIBUTORS.md)
with any new badges I've earned :-)
How to: add yourself to the [all-contributors
file](https://github.com/sktime/sktime/blob/main/.all-contributorsrc) in
the `sktime` root directory (not the `CONTRIBUTORS.md`). Common badges:
`code` - fixing a bug, or adding code logic. `doc` - writing or
improving documentation or docstrings. `bug` - reporting or diagnosing a
bug (get this plus `code` if you also fixed the bug in the
PR).`maintenance` - CI, test framework, release.
See here for [full badge
reference](https://allcontributors.org/docs/en/emoji-key)
- [ ] Optionally, I've added myself and possibly others to the
[CODEOWNERS](https://github.com/sktime/sktime/blob/main/CODEOWNERS) file
- do this if you want to become the owner or maintainer of an estimator
you added.
See here for further details on the [algorithm maintainer
role](https://www.sktime.net/en/latest/get_involved/governance.html#algorithm-maintainers).
- [X] The PR title starts with either [ENH], [MNT], [DOC], or [BUG].
[BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving
code, [DOC] - writing or improving documentation or docstrings.

##### For new estimators
- [ ] I've added the estimator to the API reference - in
`docs/source/api_reference/taskname.rst`, follow the pattern.
- [ ] I've added one or more illustrative usage examples to the
docstring, in a pydocstyle compliant `Examples` section.
- [ ] If the estimator relies on a soft dependency, I've set the
`python_dependencies` tag and ensured
dependency isolation, see the [estimator dependencies
guide](https://www.sktime.net/en/latest/developer_guide/dependencies.html#adding-a-soft-dependency).

<!--
Thanks for contributing!
-->
Bugfixing automation moved this from Needs triage & validation to Fixed/resolved Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module:tests test framework functionality - only framework, excl specific tests
Projects
Bugfixing
Fixed/resolved
Development

Successfully merging a pull request may close this issue.

3 participants