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

Refactor optional import logic and verify minimum versions #3160

Merged
merged 5 commits into from
Aug 22, 2023

Conversation

jonmmease
Copy link
Contributor

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

) from err


def import_pyarrow_interchange() -> ModuleType:
Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor Author

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(),
Copy link
Contributor Author

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.

Copy link
Contributor

@binste binste left a 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.



def import_vl_convert() -> ModuleType:
min_vlc_version = "0.12.0"
Copy link
Contributor

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:
Copy link
Contributor

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?

@jonmmease
Copy link
Contributor Author

could you glance over this once more @binste? I switched to importlib and added a section to NOTES_FOR_MAINTAINERS, so I think it's good to go.

@binste
Copy link
Contributor

binste commented Aug 22, 2023

Looks good, thanks @jonmmease! :)

@jonmmease jonmmease merged commit 8d1a7ee into main Aug 22, 2023
20 checks passed
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.

2 participants