holoviz-topics / examples

Visualization-focused examples of using HoloViz for specific topics
https://examples.holoviz.org
Creative Commons Attribution 4.0 International
80 stars 24 forks source link

NYC_buildings: Modernize notebook #386

Open Azaya89 opened 1 month ago

Azaya89 commented 1 month ago

This is a WIP PR to help with debugging the issues I'm having with this notebook. I also uploaded the new .parq file together with this PR since I don't have access to uploading it on AWS.

Modernizing an example checklist

Preliminary checks

Change ‘anaconda-project.yml’ to use the latest workable version of packages

Plot API updates (discussed on a per-example basis)

Interactivity API updates (discussed on a per-example basis)

Panel App updates (discussed on a per-example basis)

General code quality updates

Text content

Visual appearance - Example

Visual appearance - Gallery

Workflow (after you have made the changes above)

github-actions[bot] commented 1 month ago

Your changes were successfully integrated in the dev site, make sure to review the pages of the projects you touched before merging this PR: https://holoviz-dev.github.io/examples/. You can also download an archive of the site from the workflow summary page which comes in handy when your dev site built was overriden by another PR (we have a single dev site!).

Azaya89 commented 1 month ago

In this PR, pinning notebook<7 prevents geopandas from being imported, so I skipped that step. This is also causing one of the CI failures. @maximlt

maximlt commented 1 month ago

In this PR, pinning notebook<7 prevents geopandas from being imported, so I skipped that step.

Can you please add more details on this?

Azaya89 commented 1 month ago

Can you please add more details on this?

Screenshot 2024-06-07 at 6 24 33 PM

When I run cell2, here's what I get:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[2], line 3
      1 import hvplot.dask # noqa
      2 import hvplot.pandas # noqa
----> 3 import geopandas as gpd
      4 import colorcet as cc
      5 from holoviews import opts

File ~/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/lib/python3.11/site-packages/geopandas/__init__.py:3
      1 from geopandas._config import options
----> 3 from geopandas.geoseries import GeoSeries
      4 from geopandas.geodataframe import GeoDataFrame
      5 from geopandas.array import points_from_xy

File ~/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/lib/python3.11/site-packages/geopandas/geoseries.py:13
     10 from pandas import Series, MultiIndex
     11 from pandas.core.internals import SingleBlockManager
---> 13 from pyproj import CRS
     14 import shapely
     15 from shapely.geometry.base import BaseGeometry

File ~/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/lib/python3.11/site-packages/pyproj/__init__.py:33
      1 """
      2 Python interface to PROJ (https://proj.org),
      3 cartographic projections and coordinate transformations library.
   (...)
     29 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     30 """
     31 import warnings
---> 33 import pyproj.network
     34 from pyproj._datadir import (  # noqa: F401 pylint: disable=unused-import
     35     _pyproj_global_context_initialize,
     36     set_use_global_context,
     37 )
     38 from pyproj._show_versions import (  # noqa: F401 pylint: disable=unused-import
     39     show_versions,
     40 )

File ~/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/lib/python3.11/site-packages/pyproj/network.py:10
      6 from typing import Union
      8 import certifi
---> 10 from pyproj._network import (  # noqa: F401 pylint: disable=unused-import
     11     _set_ca_bundle_path,
     12     is_network_enabled,
     13     set_network_enabled,
     14 )
     17 def set_ca_bundle_path(ca_bundle_path: Union[Path, str, bool, None] = None) -> None:
     18     """
     19     .. versionadded:: 3.0.0
     20 
   (...)
     40         variables.
     41     """

ImportError: dlopen(/Users/mac/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/lib/python3.11/site-packages/pyproj/_network.cpython-311-darwin.so, 0x0002): Library not loaded: @rpath/libtiff.5.dylib
  Referenced from: <1BF0DA3A-18BF-3035-BAF9-9B25E936A309> /Users/mac/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/lib/libproj.25.9.3.1.dylib
  Reason: tried: '/Users/mac/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/lib/libtiff.5.dylib' (no such file), '/Users/mac/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/lib/python3.11/site-packages/pyproj/../../../libtiff.5.dylib' (no such file), '/Users/mac/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/lib/python3.11/site-packages/pyproj/../../../libtiff.5.dylib' (no such file), '/Users/mac/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/bin/../lib/libtiff.5.dylib' (no such file), '/Users/mac/Documents/development/holoviz-topics-examples/nyc_buildings/envs/default/bin/../lib/libtiff.5.dylib' (no such file), '/usr/local/lib/libtiff.5.dylib' (no such file), '/usr/lib/libtiff.5.dylib' (no such file, not in dyld cache)
maximlt commented 4 weeks ago

Ok it looks like a packaging issue. I don't understand why notebook<7 would influence geopandas though. Can you try to create an environment (conda create -n reproissue ...) with just pyproj, geopandas and python and the versions you have in the current lock, and see if you can reproduce the error? I'm mentioning these packages only as there are the ones that show up in the traceback you shared.

Azaya89 commented 3 weeks ago

Ok it looks like a packaging issue. I don't understand why notebook<7 would influence geopandas though. Can you try to create an environment (conda create -n reproissue ...) with just pyproj, geopandas and python and the versions you have in the current lock, and see if you can reproduce the error? I'm mentioning these packages only as there are the ones that show up in the traceback you shared.

OK, so I did create a new environment with pypoj, geopandas, python, and pyarrow and it worked well, although geopandas import took some time to load (about 20 secs):

Screenshot 2024-06-10 at 12 15 58 PM

So, i'm thinking the issue may be another dependency?

maximlt commented 3 weeks ago

@Azaya89 can you maybe try to pin again notebook<7 in the project file, re-lock, and push the changes to Github? It'd be interesting to see whether the issue you reported shows up on the CI or not.

Azaya89 commented 3 weeks ago

@Azaya89 can you maybe try to pin again notebook<7 in the project file, re-lock, and push the changes to Github? It'd be interesting to see whether the issue you reported shows up on the CI or not.

This is not able to work because doit:test ... fails dues to the same import errors.

maximlt commented 3 weeks ago

This is not able to work because doit:test ... fails dues to the same import errors.

I would like to see it failing on the CI to see if it reports the same error that you get.

github-actions[bot] commented 3 weeks ago

Your changes were successfully integrated in the dev site, make sure to review the pages of the projects you touched before merging this PR: https://holoviz-dev.github.io/examples/. You can also download an archive of the site from the workflow summary page which comes in handy when your dev site built was overriden by another PR (we have a single dev site!).

github-actions[bot] commented 3 weeks ago

Your changes were successfully integrated in the dev site, make sure to review the pages of the projects you touched before merging this PR: https://holoviz-dev.github.io/examples/. You can also download an archive of the site from the workflow summary page which comes in handy when your dev site built was overriden by another PR (we have a single dev site!).

Azaya89 commented 3 weeks ago

I think #199 is ready to be closed now @maximlt

github-actions[bot] commented 3 weeks ago

Your changes were successfully integrated in the dev site, make sure to review the pages of the projects you touched before merging this PR: https://holoviz-dev.github.io/examples/. You can also download an archive of the site from the workflow summary page which comes in handy when your dev site built was overriden by another PR (we have a single dev site!).

github-actions[bot] commented 3 days ago

Your changes were successfully integrated in the dev site, make sure to review the pages of the projects you touched before merging this PR: https://holoviz-dev.github.io/examples/. You can also download an archive of the site from the workflow summary page which comes in handy when your dev site built was overriden by another PR (we have a single dev site!).

Azaya89 commented 3 days ago

@maximlt I think this PR is ready for another review with the following notes:

  1. There is still a bit of performance issues regarding rendering of the plots and dashboard as you are already aware. It's faster than before but still slower than expected. This also affects the time it takes the tests to run (took 2:38 to run 10 cells via doit test:...)
  2. The new_nyc_buildings.parq file is the dataset used in the notebook now and so needs to be moved to S3 to replace the old one there and then deleted from the repo.
  3. The narrative about inspect_polygons was completely deleted from the notebook as it only works with spatialpandas not geopandas
maximlt commented 3 days ago

Ok thanks for the report. Depending on the performance issues, it might be that we end up not updating the code in this example.

Azaya89 commented 3 days ago

Ok thanks for the report. Depending on the performance issues, it might be that we end up not updating the code in this example.

:(