From 99374cb4db0fa47defc39de1facc9212a965a618 Mon Sep 17 00:00:00 2001 From: Johnny Chavez <64660690+calderjo@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:04:39 -0800 Subject: [PATCH] Fix Kagglehub test and Remove multiple version matplotlib files (#1441) fixing main build. - kagglehub login changes required updating our tests - latest matplotlib is needed by handful of package, but breaks learntools. i provided a workaround --- Dockerfile.tmpl | 39 +++++++++++++++++++++------------------ tests/test_kagglehub.py | 10 ++++++---- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/Dockerfile.tmpl b/Dockerfile.tmpl index 11b05ebd..ad6842ea 100644 --- a/Dockerfile.tmpl +++ b/Dockerfile.tmpl @@ -167,28 +167,12 @@ RUN pip install jax[cpu] && \ RUN export PATH=/usr/local/cuda/bin:$PATH && \ export CUDA_ROOT=/usr/local/cuda && \ pip install pycuda \ - pynvrtc \ + # TODO(379932879): pip resolver fails when not specified. + pynvrtc==9.2 \ pynvml && \ /tmp/clean-layer.sh {{ end }} -# b/308525631: Pin Matplotlib until seaborn can be upgraded -# to >0.13.0 (now it's stuck by a package conflict with ydata-profiling 4.5.1). -RUN JAXVER=$(pip freeze | grep -e "^jax==") && \ - pip install --upgrade \ - "matplotlib<3.8.0" \ - # ipympl adds interactive widget support for matplotlib - ipympl==0.7.0 \ - "seaborn==0.12.2" \ - pyupset \ - python-dateutil dask dask-expr igraph \ - pyyaml joblib geopy mne pyshp \ - pandas \ - polars \ - flax \ - "${JAXVER}" && \ - /tmp/clean-layer.sh - RUN apt-get update && \ apt-get install -y default-jre && \ /tmp/clean-layer.sh @@ -543,11 +527,30 @@ ENV TESSERACT_PATH=/usr/bin/tesseract \ # For Theano with MKL MKL_THREADING_LAYER=GNU +# b/308525631: Pin Matplotlib until seaborn can be upgraded +# to >0.13.0 (now it's stuck by a package conflict with ydata-profiling 4.5.1). +RUN JAXVER=$(pip freeze | grep -e "^jax==") && \ + pip install --upgrade \ + "matplotlib==3.7.5" \ + # ipympl adds interactive widget support for matplotlib + ipympl==0.7.0 \ + "seaborn==0.12.2" \ + pyupset \ + python-dateutil dask dask-expr igraph \ + pyyaml joblib geopy mne pyshp \ + pandas \ + polars \ + flax \ + "${JAXVER}" && \ + /tmp/clean-layer.sh + # Temporary fixes and patches # Temporary patch for Dask getting downgraded, which breaks Keras RUN pip install --upgrade dask && \ # Stop jupyter nbconvert trying to rewrite its folder hierarchy mkdir -p /root/.jupyter && touch /root/.jupyter/jupyter_nbconvert_config.py && touch /root/.jupyter/migrated && \ + # TODO(b/380921973): Ensure only matplotlib 3.7.5 files are present. + rm -r /opt/conda/lib/python3.10/site-packages/matplotlib-3.9.2.dist-info/ && \ mkdir -p /.jupyter && touch /.jupyter/jupyter_nbconvert_config.py && touch /.jupyter/migrated && \ # Stop Matplotlib printing junk to the console on first load sed -i "s/^.*Matplotlib is building the font cache using fc-list.*$/# Warning removed by Kaggle/g" /opt/conda/lib/python3.10/site-packages/matplotlib/font_manager.py && \ diff --git a/tests/test_kagglehub.py b/tests/test_kagglehub.py index 37b11248..f2c3e2a6 100644 --- a/tests/test_kagglehub.py +++ b/tests/test_kagglehub.py @@ -8,8 +8,10 @@ class TestKagglehub(unittest.TestCase): def test_login(self): with self.assertLogs('kagglehub', level='INFO') as l: with mock.patch("builtins.input") as mock_input: - mock_input.side_effect = ["lastplacelarry", "some-key"] - # Disabling credentials validation since network access is disabled in unittest. - kagglehub.login(validate_credentials=False) + with mock.patch("getpass.getpass") as mock_getpass: + mock_input.side_effect = ["lastplacelarry"] + mock_getpass.return_value = "some-key" - self.assertIn("credentials set", l.output[0]) + kagglehub.login(validate_credentials=False) + + self.assertIn("credentials set", l.output[0])