Skip to content

Avoid eager optional comparator imports#2153

Closed
aseembits93 wants to merge 2 commits into
mainfrom
fix-lazy-comparator-optional-imports
Closed

Avoid eager optional comparator imports#2153
aseembits93 wants to merge 2 commits into
mainfrom
fix-lazy-comparator-optional-imports

Conversation

@aseembits93
Copy link
Copy Markdown
Contributor

Summary

  • lazily import optional comparator libraries only when comparing objects from those modules
  • prevent comparator import from loading pandas/xarray/numexpr during CLI startup
  • add a regression test for optional numeric module imports

Tests

  • uv run pytest tests/test_comparator.py -q
  • uv run ruff check codeflash/verification/comparator.py --no-fix
  • uv run codeflash --help

Comment on lines +97 to +101
@cache
def _optional_module(module_name: str) -> Optional[Any]:
if find_spec(module_name) is None:
return None
return import_module(module_name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if this is for import time then just remove the entire block and import on demand https://github.com/KRRT7/codeflash/pull/16/changes#diff-a6f2493dbc3f1ec576d03e2d188986f94ca475e3b4cf79ba3dff06309ec01997

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