Skip to content

Commit

Permalink
Fix Kagglehub test and Remove multiple version matplotlib files (#1441)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
calderjo authored Nov 25, 2024
1 parent 34427a2 commit 99374cb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
39 changes: 21 additions & 18 deletions Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 && \
Expand Down
10 changes: 6 additions & 4 deletions tests/test_kagglehub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

0 comments on commit 99374cb

Please sign in to comment.