Skip to content

Commit

Permalink
cherry-pick h5py issue fix (mlflow#3671)
Browse files Browse the repository at this point in the history
* cherry-pick h5py issue

Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>

* empty

Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
  • Loading branch information
harupy authored Nov 11, 2020
1 parent 93e505b commit 4582e46
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion dev/extra-ml-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
azureml-sdk==1.2.0
# Required by mlflow.keras
keras==2.3.1
# Pin h5py < 3.0.0 to avoid this issue: https://github.com/h5py/h5py/issues/1732
# Pin h5py < 3.0.0 to avoid this issue: https://github.com/tensorflow/tensorflow/issues/44467
# TODO: unpin after we use tensorflow >= 2.4
h5py<3.0.0
# Required by mlflow.sklearn
scikit-learn
Expand Down
3 changes: 2 additions & 1 deletion mlflow/R/mlflow/.create-test-env.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ library(reticulate)
use_condaenv(mlflow:::mlflow_conda_env_name())
# pinning tensorflow version to 1.14 until test_keras_model.R is fixed
keras::install_keras(method = "conda", envname = mlflow:::mlflow_conda_env_name(), tensorflow="1.15.2")
# pinning h5py < 3.0.0 to avoid this issue: https://github.com/h5py/h5py/issues/1732
# pinning h5py < 3.0.0 to avoid this issue: https://github.com/tensorflow/tensorflow/issues/44467
# TODO: unpin after we use tensorflow >= 2.4
reticulate::conda_install("'h5py<3.0.0'", envname = mlflow:::mlflow_conda_env_name(), pip = TRUE)
reticulate::conda_install(Sys.getenv("MLFLOW_HOME", "../../../../."), envname = mlflow:::mlflow_conda_env_name(), pip = TRUE)
reticulate::conda_install("xgboost", envname = mlflow:::mlflow_conda_env_name())
Expand Down
5 changes: 5 additions & 0 deletions mlflow/keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def get_default_conda_env(include_cloudpickle=False, keras_module=None):
else:
pip_deps.append("tensorflow=={}".format(tf.__version__))

# Tensorflow<2.4 does not work with h5py>=3.0.0
# see https://github.com/tensorflow/tensorflow/issues/44467
if LooseVersion(tf.__version__) < LooseVersion("2.4"):
pip_deps.append("h5py<3.0.0")

return _mlflow_conda_env(
additional_conda_deps=conda_deps,
additional_pip_deps=pip_deps,
Expand Down
7 changes: 4 additions & 3 deletions tests/keras/test_keras_model_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ def _import_module(name, **kwargs):
assert x == b


@pytest.mark.skip("Unskip this test once https://github.com/h5py/h5py/issues/1732 is fixed")
@pytest.mark.parametrize("build_model", [model, tf_keras_model])
@pytest.mark.parametrize(
"build_model,save_format",
[(model, None), (tf_keras_model, None), (tf_keras_model, "h5"), (tf_keras_model, "tf")],
)
@pytest.mark.large
def test_model_save_load(build_model, model_path, data):
x, _ = data
Expand Down Expand Up @@ -269,7 +271,6 @@ def test_signature_and_examples_are_saved_correctly(model, data):
assert all((_read_example(mlflow_model, path) == example).all())


@pytest.mark.skip("Unskip this test once https://github.com/h5py/h5py/issues/1732 is fixed")
@pytest.mark.large
def test_custom_model_save_load(custom_model, custom_layer, data, custom_predicted, model_path):
x, _ = data
Expand Down

0 comments on commit 4582e46

Please sign in to comment.