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

Fix logic for no geoviews explorer #1451

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

ahuang11
Copy link
Collaborator

Even though geo=False, explorer would raise raise ImportError('GeoViews must be installed to enable the geographic options.')

import pandas as pd
import hvplot.pandas
df = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})

df.hvplot.explorer(geo=False)

Not sure how to add a test for this because the dev dependencies installs geoviews.

@ahuang11 ahuang11 requested a review from maximlt October 29, 2024 20:37
@hoxbro
Copy link
Member

hoxbro commented Oct 29, 2024

@ahuang11
Copy link
Collaborator Author

ooh that's fancy and good to know! Turns out there actually was a marker for geo tests so I didn't need it.

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.03%. Comparing base (9078378) to head (0054eea).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1451      +/-   ##
==========================================
+ Coverage   88.94%   89.03%   +0.08%     
==========================================
  Files          52       52              
  Lines        7781     7794      +13     
==========================================
+ Hits         6921     6939      +18     
+ Misses        860      855       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hoxbro
Copy link
Member

hoxbro commented Oct 30, 2024

Are you sure?

@maximlt
Copy link
Member

maximlt commented Oct 30, 2024

ooh that's fancy and good to know! Turns

It's also a little crazy right 🙃

A suggestion could be to refactor gv_available into a utility function that is mocked for this test to return False.

@ahuang11
Copy link
Collaborator Author

Hm I guess there is a marker, but the tests still run everything
https://github.com/holoviz/hvplot/blob/main/.github/workflows/test.yaml#L171
https://github.com/holoviz/hvplot/blob/main/hvplot/tests/testui.py#L394

I guess I'll go with Maxime's suggestion

hvplot/util.py Outdated Show resolved Hide resolved
gv_available = find_spec('geoviews') is not None

if not gv_available and raise_error:
raise ImportError('GeoViews must be installed to enable the geographic options.')
Copy link
Member

Choose a reason for hiding this comment

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

I got confused a minute here, does find_spec('geoviews') actually import GeoViews?

Copy link
Member

Choose a reason for hiding this comment

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

No, but it checks if it is installed.

image

Copy link
Member

Choose a reason for hiding this comment

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

Yes ok that's what I thought. I was confused as then an ImportError is raised. Since importing GeoViews comes with side effects (registering lots of stuff), I'd like to make sure we're not removing an important step there. @hoxbro did you suggest find_spec for performance reasons?

Copy link
Member

Choose a reason for hiding this comment

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

Just as an alternative and also easier to patch in the test suite.

I think it is okay to use find_spec when we check if it is available. We should import geoviews in the code, where there previously was a try/except, to get those juicy side effects.

Copy link
Member

Choose a reason for hiding this comment

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

I also think the error message is wrong here. As it no longer only affects the UI code.

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.

3 participants