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

docker: prevent manual pin of dependencies and improve build speed #95

Merged
merged 70 commits into from Jan 27, 2022

Conversation

tlvu
Copy link
Contributor

@tlvu tlvu commented Dec 21, 2021

Overview

Previously, when xclim and ravenpy were pinning their own dependencies, the pins were ignored and we had to manually repeat the same pins again. See comment #94 (comment).

This PR allows xclim and ravenpy to manage their own dependencies pinning transparently during this Jupyter env rebuild.

Also fixed a long standing build performance along the way. Build time went from 50 mins to 25 mins and builds on DockerHub works again (fixes #51).

Deployed as "beta" image on https://pavics.ouranos.ca/jupyter for testing.

Changes

  • Switched to using mamba instead of conda since mamba dependency solver is faster. Mamba solver being faster at the expense of less precision so had to pin latest xclim and ravenpy to avoid random downgrade in the 2nd build phase.

    Both solvers performance seem to drop exponentially when less packages are specified directly, leading to more work for the solver to discover them. Less packages specified directly because we removed all direct dependencies of xclim and ravenpy from the environment.yml file.

  • Switched to using 2 stages conda env build as another performance work-around. One single conda env create -f /environment.yml was taking many days ! mamba was not much better in one single stage build.

    With 2 stages build, a build using conda solver takes 5 hours while mamba solver takes 25 minutes !

  • Reduced the number of "build layers" by merging several of them, for another small build performance gain.

  • jupyterlab-topbar-text and jupyterlab-theme-toggle jupyterlab extension was removed due to javascript build problem. The topbar text was pretty useless. Hopefully the theme toogle is not so widely used.

  • Had to hardcode the commit of the https://github.com/jupyter/docker-stacks repo where we get the startup script from because the latest version of those scripts are breaking us. This will have to be solve later.

  • Removed vcs library from cdat channel in order to move to python 3.9. Otherwise we are stuck on 3.7 and xarray will drop 3.7 soon. I've opened an issue on CDAT side Unable to install vcs conda package in a python 3.9 environment: package vcs-8.1-py_0 requires vtk-cdat >8.1, but none of the providers can be installed CDAT/vcs#457. vcs library was needed to run ESGF notebooks at https://github.com/ESGF/esgf-compute-api/tree/devel/examples

Related Issue / Discussion

Additional Information

  • Screenshot of UI change showing jupyterlab-topbar-text and jupyterlab-theme-toggle jupyterlab extension removed:
    Screenshot from 2021-12-21 17-10-25

  • Relevant changes:

<   - xclim=0.31.0=pyhd8ed1ab_0
>   - xclim=0.32.1=pyhd8ed1ab_0

<   - ravenpy=0.7.5=pyhff6ddc9_0
>   - ravenpy=0.7.8=pyh8a188c0_0

<   - python=3.7.12=hb7a2778_100_cpython
>   - python=3.8.12=hb7a2778_2_cpython

# removed
<   - vcs=8.2.1=pyh9f0ad1d_0

<   - numpy=1.21.4=py37h31617e3_0
>   - numpy=1.21.5=py38h87f13fb_0

<   - xarray=0.20.1=pyhd8ed1ab_0
>   - xarray=0.20.2=pyhd8ed1ab_0

<   - rioxarray=0.8.0=pyhd8ed1ab_0
>   - rioxarray=0.9.1=pyhd8ed1ab_0

<   - cf_xarray=0.6.1=pyh6c4a22f_0
>   - cf_xarray=0.6.3=pyhd8ed1ab_0

<   - gdal=3.3.2=py37hd5a0ba4_2
>   - gdal=3.3.3=py38hcf2042a_0

<   - rasterio=1.2.6=py37hc20819c_2
>   - rasterio=1.2.10=py38hfd64e68_0

<   - climpred=2.1.6=pyhd8ed1ab_1
>   - climpred=2.2.0=pyhd8ed1ab_0

<   - clisops=0.7.0=pyh6c4a22f_0
>   - clisops=0.8.0=pyh6c4a22f_0

<   - xesmf=0.6.0=pyhd8ed1ab_0
>   - xesmf=0.6.2=pyhd8ed1ab_0

<   - birdy=v0.8.0=pyh6c4a22f_1
>   - birdy=0.8.1=pyh6c4a22f_1

<   - cartopy=0.20.0=py37hbe109c4_0
>   - cartopy=0.20.1=py38hf9a4893_1

<   - dask=2021.11.2=pyhd8ed1ab_0
>   - dask=2022.1.0=pyhd8ed1ab_0

<   - numba=0.53.1=py37hb11d6e1_1
>   - numba=0.55.0=py38h4bf6c61_0

<   - pandas=1.3.4=py37he8f5f7f_1
>   - pandas=1.3.5=py38h43a58ef_0
  • Full diff of conda env export:

211123-update211216-211221-conda-env-export.diff.txt

211221-220116.1-conda-env-export.diff.txt

211123-update211216-220116.1-conda-env-export.diff.txt

220116.1-220121-conda-env-export.diff.txt

211123-update211216-220121-conda-env-export.diff.txt

  • Full new conda env export:

211221-conda-env-export.yml.txt

220116.1-conda-env-export.yml.txt

220121-conda-env-export.yml.txt

…yter lab v3 anymore, causing us build problems now
Encountered problems while solving:
  - package vcs-8.1-py_0 requires vtk-cdat >8.1, but none of the providers can be installed
This reverts commit 498bc8c.

vtk-cdat was already part of cdat repo.
…enssl significantly

```
-  # - openssl 3.0.0 h7f98852_2 installed
-  # + openssl 1.1.1l h7f98852_0 conda-forge/linux-64 2 MB
```
@tlvu
Copy link
Contributor Author

tlvu commented Jan 14, 2022

FYI @ChaamC I am at the end of road with this jupyter-conda plugin problem, I've opened an issue on their side to get more help mamba-org/gator#170

docker/environment.yml Outdated Show resolved Hide resolved
@tlvu tlvu mentioned this pull request Jan 14, 2022
Copy link
Collaborator

@Zeitsperre Zeitsperre left a comment

Choose a reason for hiding this comment

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

Python3.10 makes breaking changes to several standard libraries (collections, types, typing). It looks as though we might need to make changes to a few dependencies (or help push new versions) if we want to maintain support for newer versions.

# Conda was stuck at this step:
# DEBUG conda.common._logic:_run_sat(607): Invoking SAT with clause count: 2500273
#
# Pin python=3.9 because python 3.10 cause this error:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Additionally, PyDAP is not Python3.10 compatible. On import:

...
File ~/miniconda3/envs/pavics-sdi/lib/python3.10/site-packages/pydap/model.py:175, in <module>
    173 from six import string_types
    174 import numpy as np
--> 175 from collections import OrderedDict, Mapping
    176 import warnings
    178 from .lib import quote, decode_np_strings

ImportError: cannot import name 'Mapping' from 'collections' (/home/me/miniconda3/envs/pavics-sdi/lib/python3.10/collections/__init__.py)

@tlvu
Copy link
Contributor Author

tlvu commented Jan 18, 2022

@tlogan2000

I pinned shapely to the old 1.7.1 version and there is a new failure with the homepage nb 5: http://jenkins.ouranos.ca/job/PAVICS-e2e-workflow-tests/job/prevent-manual-pin-of-dependencies/14/consoleFull

12:36:36  File /opt/conda/envs/birdy/lib/python3.9/site-packages/holoviews/core/data/xarray.py:224, in XArrayInterface.init(cls, eltype, data, kdims, vdims)
12:36:36      220     undeclared = [
12:36:36      221         c for c in da.coords if c not in kdims and len(da[c].shape) == 1 and
12:36:36      222         da[c].shape[0] > 1]
12:36:36      223     if undeclared:
12:36:36  --> 224         raise DataError(
12:36:36      225             'The coordinates on the %r DataArray do not match the '
12:36:36      226             'provided key dimensions (kdims). The following coords '
12:36:36      227             'were left unspecified: %r. If you are requesting a '
12:36:36      228             'lower dimensional view such as a histogram cast '
12:36:36      229             'the xarray to a columnar format using the .to_dataframe '
12:36:36      230             'or .to_dask_dataframe methods before providing it to '
12:36:36      231             'HoloViews.' % (vdim.name, undeclared))
12:36:36      232 return data, {'kdims': kdims, 'vdims': vdims}, {}
12:36:36  
12:36:36  DataError: The coordinates on the 'tx_mean' DataArray do not match the provided key dimensions (kdims). The following coords were left unspecified: ['horizon']. If you are requesting a lower dimensional view such as a histogram cast the xarray to a columnar format using the .to_dataframe or .to_dask_dataframe methods before providing it to HoloViews.

A good news is the bokeh/holoviews performance problem seems to be fixed in the new build.

This new build is deployed as "beta" image in prod.

@tlogan2000
Copy link
Collaborator

I'll take a look.

Sample error:

```
  _______ pavics-sdi-master/docs/source/notebooks/forecasts.ipynb::Cell 2 ________
  Notebook cell execution failed
  Cell 2: Cell outputs differ

  Input:
  import hvplot.xarray
  mtl = ds.sel(lon=45.5, lat=360 - 73.5, method="nearest")
  mtl.pr.hvplot(x="time", width=300) + mtl.tas.hvplot(x="time", width=300)

  Traceback:
   mismatch 'application/vnd.holoviews_load.v0+json'

   assert reference_output == test_output failed:

    '\n(function(...\n}(window));' == '\n(function(...\n}(window));'
    Skipping 1273 identical leading characters in diff, use -v to show
      , now());
    +     root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length;

          function on_load() {
            root._bokeh_is_loading--;
            if (root._bokeh_is_loading === 0) {
              console.debug("Bokeh: all BokehJS libraries/stylesheets loaded");
              run_callbacks()
            }
          }

  ( ... )
```
@tlvu
Copy link
Contributor Author

tlvu commented Jan 20, 2022

@ChaamC FYI the jupyter-conda plugin is fixed by uninstalling mamba from the image !

tlvu added a commit to bird-house/birdhouse-deploy that referenced this pull request Jan 27, 2022
Deploy new Jupyter env from PR Ouranosinc/PAVICS-e2e-workflow-tests#95 on PAVICS.

Detailed changes can be found at Ouranosinc/PAVICS-e2e-workflow-tests#95.

Relevant changes:
```diff
<   - xclim=0.31.0=pyhd8ed1ab_0
>   - xclim=0.32.1=pyhd8ed1ab_0

<   - ravenpy=0.7.5=pyhff6ddc9_0
>   - ravenpy=0.7.8=pyh8a188c0_0

<   - python=3.7.12=hb7a2778_100_cpython
>   - python=3.8.12=hb7a2778_2_cpython

<   - vcs=8.2.1=pyh9f0ad1d_0

<   - numpy=1.21.4=py37h31617e3_0
>   - numpy=1.21.5=py38h87f13fb_0

<   - xarray=0.20.1=pyhd8ed1ab_0
>   - xarray=0.20.2=pyhd8ed1ab_0

<   - rioxarray=0.8.0=pyhd8ed1ab_0
>   - rioxarray=0.9.1=pyhd8ed1ab_0

<   - cf_xarray=0.6.1=pyh6c4a22f_0
>   - cf_xarray=0.6.3=pyhd8ed1ab_0

<   - gdal=3.3.2=py37hd5a0ba4_2
>   - gdal=3.3.3=py38hcf2042a_0

<   - rasterio=1.2.6=py37hc20819c_2
>   - rasterio=1.2.10=py38hfd64e68_0

<   - climpred=2.1.6=pyhd8ed1ab_1
>   - climpred=2.2.0=pyhd8ed1ab_0

<   - clisops=0.7.0=pyh6c4a22f_0
>   - clisops=0.8.0=pyh6c4a22f_0

<   - xesmf=0.6.0=pyhd8ed1ab_0
>   - xesmf=0.6.2=pyhd8ed1ab_0

<   - birdy=v0.8.0=pyh6c4a22f_1
>   - birdy=0.8.1=pyh6c4a22f_1

<   - cartopy=0.20.0=py37hbe109c4_0
>   - cartopy=0.20.1=py38hf9a4893_1

<   - dask=2021.11.2=pyhd8ed1ab_0
>   - dask=2022.1.0=pyhd8ed1ab_0

<   - numba=0.53.1=py37hb11d6e1_1
>   - numba=0.55.0=py38h4bf6c61_0

<   - pandas=1.3.4=py37he8f5f7f_1
>   - pandas=1.3.5=py38h43a58ef_0
```
@tlvu tlvu merged commit 607ec58 into master Jan 27, 2022
@tlvu tlvu deleted the prevent-manual-pin-of-dependencies branch January 27, 2022 14:36
tlvu added a commit to bird-house/birdhouse-deploy that referenced this pull request Jan 27, 2022
Jupyter: update Jupyter env for latest XClim, RavenPy and all packages

Deploy new Jupyter env from PR Ouranosinc/PAVICS-e2e-workflow-tests#95 on PAVICS.

Detailed changes can be found at Ouranosinc/PAVICS-e2e-workflow-tests#95.

Relevant changes:
```diff
<   - xclim=0.31.0=pyhd8ed1ab_0
>   - xclim=0.32.1=pyhd8ed1ab_0

<   - ravenpy=0.7.5=pyhff6ddc9_0
>   - ravenpy=0.7.8=pyh8a188c0_0

<   - python=3.7.12=hb7a2778_100_cpython
>   - python=3.8.12=hb7a2778_2_cpython

<   - vcs=8.2.1=pyh9f0ad1d_0

<   - numpy=1.21.4=py37h31617e3_0
>   - numpy=1.21.5=py38h87f13fb_0

<   - xarray=0.20.1=pyhd8ed1ab_0
>   - xarray=0.20.2=pyhd8ed1ab_0

<   - rioxarray=0.8.0=pyhd8ed1ab_0
>   - rioxarray=0.9.1=pyhd8ed1ab_0

<   - cf_xarray=0.6.1=pyh6c4a22f_0
>   - cf_xarray=0.6.3=pyhd8ed1ab_0

<   - gdal=3.3.2=py37hd5a0ba4_2
>   - gdal=3.3.3=py38hcf2042a_0

<   - rasterio=1.2.6=py37hc20819c_2
>   - rasterio=1.2.10=py38hfd64e68_0

<   - climpred=2.1.6=pyhd8ed1ab_1
>   - climpred=2.2.0=pyhd8ed1ab_0

<   - clisops=0.7.0=pyh6c4a22f_0
>   - clisops=0.8.0=pyh6c4a22f_0

<   - xesmf=0.6.0=pyhd8ed1ab_0
>   - xesmf=0.6.2=pyhd8ed1ab_0

<   - birdy=v0.8.0=pyh6c4a22f_1
>   - birdy=0.8.1=pyh6c4a22f_1

<   - cartopy=0.20.0=py37hbe109c4_0
>   - cartopy=0.20.1=py38hf9a4893_1

<   - dask=2021.11.2=pyhd8ed1ab_0
>   - dask=2022.1.0=pyhd8ed1ab_0

<   - numba=0.53.1=py37hb11d6e1_1
>   - numba=0.55.0=py38h4bf6c61_0

<   - pandas=1.3.4=py37he8f5f7f_1
>   - pandas=1.3.5=py38h43a58ef_0
```
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.

DockerHub build failed at conda env create command with connection broken error
5 participants