-
Notifications
You must be signed in to change notification settings - Fork 799
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
Refactor optional import logic and verify minimum versions #3160
Conversation
Set minimum vegafusion version to 1.4.0 and minimum vl_convert version to 0.12.0.
) from err | ||
|
||
|
||
def import_pyarrow_interchange() -> ModuleType: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the others, I updated this to use pa.__version__
directly rather than importlib.metadata.version
. Does anyone recall whether there was a particular reason to use importlib?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__version__
is not a required property of a Python package, I think it could for example be defined only in pyproject.toml without exposing __version__
. I've also recently seen a deprecation warning of a package when accessing __version__
. importlib.metadata.version
is a more general and robust way to retrieve the version information based on the metadata of a package.
Although __version__
works for all these packages, I'd slightly prefer importlib
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are good points, I'll look at switching over to importlib
.
import_pyarrow_interchange() | ||
return True | ||
except ImportError: | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to util._importers
vega_spec, | ||
dataset_names, | ||
get_local_tz(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now the default value of the local_tz
argument in VegaFusion 1.4.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I only added some minor comments.
altair/utils/_importers.py
Outdated
|
||
|
||
def import_vl_convert() -> ModuleType: | ||
min_vlc_version = "0.12.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this version number determined by what Vega-Lite version is bundled in VLC? If yes, could you add a bullet point to the Updating the Vega-Lite version
section in NOTES_FOR_MAINTAINERS.md
to update this version number every time we update Vega-Lite?
) from err | ||
|
||
|
||
def import_pyarrow_interchange() -> ModuleType: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__version__
is not a required property of a Python package, I think it could for example be defined only in pyproject.toml without exposing __version__
. I've also recently seen a deprecation warning of a package when accessing __version__
. importlib.metadata.version
is a more general and robust way to retrieve the version information based on the metadata of a package.
Although __version__
works for all these packages, I'd slightly prefer importlib
. What do you think?
could you glance over this once more @binste? I switched to |
Looks good, thanks @jonmmease! :) |
This PR moves the optional import logic for pyarrow, vegafusion, and vl-convert to
util._importers
and checks for minimum supported versions of vegafusion (1.4.0) and vl-convert (0.12.0).