Skip to content

Use new lazy_import function to lazily import third-party libraries #331

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

Merged
merged 4 commits into from
Apr 30, 2025

Conversation

abrookins
Copy link
Collaborator

Uses the new lazy_import utility from: #330

@abrookins abrookins marked this pull request as draft April 29, 2025 00:23
@abrookins abrookins marked this pull request as ready for review April 29, 2025 18:54
@abrookins abrookins requested a review from Copilot April 29, 2025 21:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request updates various modules to use the new lazy_import utility for third-party libraries, streamlining imports and potentially reducing startup overhead. Key changes include switching direct imports of numpy, nltk, tabulate, and ml_dtypes to lazy imports across multiple files and adjusting the test setup for bfloat16 handling.

  • Migrate direct module imports to lazy_import where applicable
  • Update various utility functions and CLI components to adopt lazy imports
  • Adjust testing code to handle special cases for bfloat16 imports

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/test_utils.py Adjusted handling for bfloat16 testing with explicit ml_dtypes import
redisvl/utils/optimize/utils.py Replaced numpy import with lazy_import
redisvl/utils/optimize/router.py Replaced numpy import with lazy_import
redisvl/utils/optimize/cache.py Replaced numpy import with lazy_import
redisvl/redis/utils.py Migrated numpy and ml_dtypes import to lazy_import at module level, but retains explicit import for bfloat16 in utility functions
redisvl/query/query.py & aggregate.py Replaced nltk and its stopwords import with lazy_import
redisvl/cli/stats.py & index.py Updated tabulate import to lazy_import

Copy link
Collaborator

@tylerhutcherson tylerhutcherson left a comment

Choose a reason for hiding this comment

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

LGTM beyond what the copilot is asking and my note about the helper function we have.

@abrookins abrookins changed the base branch from feat/RAAE-779-lazy-imports to 0.6.0 April 30, 2025 14:48
@abrookins abrookins merged commit 89943ec into 0.6.0 Apr 30, 2025
31 checks passed
abrookins added a commit that referenced this pull request May 1, 2025
abrookins added a commit that referenced this pull request May 1, 2025
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