Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a small “PyKale-style” public API surface to kalelinear by introducing kalelinear.embed and kalelinear.predict modules that re-export the main transformer and estimator classes, and wires them into the package namespace for convenient access.
Changes:
- Add
kalelinear/embed.pyandkalelinear/predict.pymodules that re-export key transformers/estimators via__all__. - Update
kalelinear/__init__.pyto exposeembedandpredictas lazily-imported top-level attributes and bump version metadata. - Add a public API test ensuring these modules expose the expected symbols.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_public_api.py | Adds tests validating kalelinear.embed / kalelinear.predict expose the expected class names. |
| kalelinear/predict.py | Introduces a thin re-export module for estimator classes under a stable public API. |
| kalelinear/embed.py | Introduces a thin re-export module for transformer classes under a stable public API. |
| kalelinear/init.py | Exposes embed/predict via module-level lazy import (__getattr__) and updates package metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
kalelinear/init.py:19
__getattr__lazily importsembed/predictbut doesn’t cache the imported module on the package. This means every attribute access (e.g.,kalelinear.embed) re-enters__getattr__and re-callsimport_module(even though it returns fromsys.modules). Caching the module inglobals()avoids repeated lookups and matches the typical PEP 562 lazy-import pattern.
def __getattr__(name):
if name in __all__:
return import_module(f"{__name__}.{name}")
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
There was a problem hiding this comment.
🟡 Not ready to approve
README.md is now used as the PyPI long description, but the new logo image uses a relative path that will render as broken on PyPI unless switched to an absolute URL (or removed).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Review details
Comments suppressed due to low confidence (1)
README.md:2
- The README is now used as the PyPI long_description (setup.py reads README.md), but this image uses a relative path that won’t resolve on PyPI, so it will render as a broken image outside of GitHub. Use an absolute URL (e.g., raw GitHub URL) or remove the image from the long_description content.
<img src="docs/images/kalelinear.jpg" width="60%" alt="kalelinear logo" />
- Files reviewed: 12/13 changed files
- Comments generated: 0 new
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
There was a problem hiding this comment.
🟡 Not ready to approve
The README logo currently points at a GitHub /tree/ URL (won’t render as an image reliably), and the lazy-loading behavior introduced in __getattr__ is not directly exercised by the new tests.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Review details
Suppressed comments (2)
README.md:3
- The README logo uses a GitHub
/tree/URL, which serves an HTML page rather than the raw JPEG, so the image will not render correctly (e.g., on PyPI and some Markdown renderers). Point thesrcat a raw/blob URL instead.
<p align="center">
<img src="https://github.com/pykale/linear/tree/main/docs/images/kalelinear.jpg" width="60%" alt="kalelinear logo" />
</p>
tests/test_public_api.py:27
- The new tests import
embed/predict(and other submodules) viafrom kalelinear import ..., which will pass even ifkalelinear.__getattr__is broken because the import machinery can load submodules directly. To actually cover the lazy attribute-loading behavior added inkalelinear/__init__.py, add a test that clears the cached attributes/modules and then accesseskalelinear.embed/kalelinear.predictvia attribute access.
def test_lazy_modules_are_cached_on_package():
assert kalelinear.transformer is transformer
assert kalelinear.estimator is estimator
assert kalelinear.embed is embed
assert kalelinear.predict is predict
- Files reviewed: 12/13 changed files
- Comments generated: 0 new
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
There was a problem hiding this comment.
🟢 Ready to approve
The compatibility modules and lazy-loading behavior are implemented coherently and are validated by targeted public API tests, with documentation and packaging updates aligned to the change.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Review details
- Files reviewed: 12/13 changed files
- Comments generated: 0 new
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
Add two APIs
embedandpredict, which are equivalent totransformerandestimators, for compatibility with thekalelibrary APIs.