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

Modernize notebook: heat_and_trees #395

Open Azaya89 opened 1 month ago

Azaya89 commented 1 month ago

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!).

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!).

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 3 weeks ago

Comments on the warnings displayed:

1.

FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.

This particular warning message indicates an upcoming change in the behavior of the Dataset.dims property in a future version of the xarray library. However, the version of xarray currently in use in this PR already returns the set of dimension names when Dataset.dims is checked, which renders this warning redundant.

2.

OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.

There is an open PR here that should fix the warning.

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!).

maximlt commented 2 weeks ago
FutureWarning: The return type of `Dataset.dims` will be changed to return a set of dimension names in future, in order to be more consistent with `DataArray.dims`. To access a mapping from dimension names to lengths, please use `Dataset.sizes`.

This particular warning message indicates an upcoming change in the behavior of the Dataset.dims property in a future version of the xarray library. However, the version of xarray currently in use in this PR already returns the set of dimension names when Dataset.dims is checked, which renders this warning redundant.

The full warning I have is:

/Users/mliquet/dev/examples/heat_and_trees/envs/default/lib/python3.11/site-packages/intake_xarray/raster.py:108: FutureWarning: The return type of Dataset.dims will be changed to return a set of dimension names in future, in order to be more consistent with DataArray.dims. To access a mapping from dimension names to lengths, please use Dataset.sizes. 'dims': dict(ds2.dims),

You'll notice it is attributed to line 108 in the file intake_xarray/raster.py. I put a breakpoint in the code to debug it and print the variables ds2.dims (the one causing the warning) and ds2.sizes (the one recommended for update):

ipdb> ds2.dims
FrozenMappingWarningOnValuesAccess({'x': 7741, 'y': 7871, 'band': 4})
ipdb> ds2.sizes
Frozen({'x': 7741, 'y': 7871, 'band': 4})

At the moment, with version 2024.6.0 of xarray, ds2.dims return a mapping from dimension names to their length. The warning explains this behavior is going to change in the future, ds2.dims will return a set object that only includes the dimension names. Let's now have a look at intake-xarray's code to see what it does withds2.dims:

            metadata = {
                'dims': dict(ds2.dims),
                'data_vars': {k: list(ds2[k].coords)
                              for k in ds2.data_vars.keys()},
                'coords': tuple(ds2.coords.keys()),
                'array': 'raster'
            }

You can see it calls dict(ds2.dims) which basically just casts the special mapping object returned by ds2.dims to a standard Python dictionary. So in the future, when ds2.dims returns just a set object, this code will break! As such, intake-xarray needs to be updated! Can you please open an issue on the Github repository of intake-xarray to report this problem, and open a PR to fix it? I think updating to 'dims': dict(ds2.sizes) should be enough, assuming the sizes property has been there long enough.

However, the version of xarray currently in use in this PR already returns the set of dimension names when Dataset.dims is checked, which renders this warning redundant.

Yes but part of the exercise was to open issues in other projects to let them know that their library emits a warning when used.

Azaya89 commented 2 weeks ago

At the moment, with version 2024.6.0 of xarray, ds2.dims return a mapping from dimension names to their length. The warning explains this behavior is going to change in the future, ds2.dims will return a set object that only includes the dimension names. Let's now have a look at intake-xarray's code to see what it does withds2.dims:

I'm still a bit confused by this 'cos this is what ds.dims returns for me:

Screenshot 2024-06-19 at 11 19 16 AM

which tells me that it's already exhibiting the future behaviour. Is there something I'm missing?

Azaya89 commented 2 weeks ago

I'm also getting this same error when I run doit validate:..., should I just ignore it or is there a way to resolve it currently?

Azaya89 commented 1 week ago

I created an Issue here https://github.com/intake/intake-xarray/issues/145 concerning the FutureWarning, although I can see that the last update in that repo was 9 months ago...

maximlt commented 1 week ago

I created an Issue here intake/intake-xarray#145 concerning the FutureWarning, although I can see that the last update in that repo was 9 months ago...

Cool thanks! Can you now fork the repo and open a PR to fix this issue as suggested in https://github.com/holoviz-topics/examples/pull/395#issuecomment-2178020736?

maximlt commented 1 week ago

I can see that the last update in that repo was 9 months ago...

Some projects don't need much update :)

Azaya89 commented 1 week ago

Cool thanks! Can you now fork the repo and open a PR to fix this issue as suggested in #395 (comment)?

Done here

maximlt commented 1 week ago

Cool thanks! Can you now fork the repo and open a PR to fix this issue as suggested in #395 (comment)?

Done here

Thanks! I see it got already merged 👍

github-actions[bot] commented 5 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!).

maximlt commented 5 days ago

@Azaya89 I made some updates to move the download of the two GeoJSON files to the intake catalog. I know we said we wanted to move away from intake but this is more work than I'm ready to put in at the moment, IMO we'll have to stick with intake for now.

Azaya89 commented 5 days ago

Is this PR ready to be merged now @maximlt ?

github-actions[bot] commented 5 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!).

maximlt commented 5 days ago

Is this PR ready to be merged now @maximlt ?

I updated the branch to get a dev site build and check how it looks. If it's okay, I'll merge it.

github-actions[bot] commented 5 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 4 days ago

Probably need to set cnorm to get the same output as before.

Done

github-actions[bot] commented 4 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!).