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

Make imports of heavy packages lazy #491

Merged
merged 6 commits into from
May 9, 2024
Merged

Conversation

jonmmease
Copy link
Collaborator

@jonmmease jonmmease commented May 9, 2024

Improve VegaFusion import time by making the imports of the following packages lazy:

  • pyarrow
  • polars
  • pandas
  • duckdb
  • altair

Previously these would all be imported eagerly if they are installed, which could lead to multi-second import time if VegaFusion is used in an environment where they are all installed.

To make it easier to make altair lazy, I updated the transformed_data function to delegate to the Altair implementation.

@@ -82,6 +81,3 @@ def spec_to_mime_bundle(
return {"image/png": png}
else:
raise ValueError(f"Unsupported mimetype: {mimetype}")


alt.renderers.register('vegafusion-mime', vegafusion_mime_renderer)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now registered using an entry point to avoid the need to import altair

return None
group = child_group

return group
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved out from evaluation.py since it's not used there any more



alt.data_transformers.register("vegafusion-feather", feather_transformer)
alt.data_transformers.register("vegafusion-inline", inline_data_transformer)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to entry point for registration so as to not import altair for register

@jonmmease jonmmease merged commit 2bd7c03 into main May 9, 2024
21 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.

None yet

1 participant