Skip to content

Add kale naming APIs - #16

Merged
shuo-zhou merged 8 commits into
mainfrom
kale-api
Aug 1, 2026
Merged

Add kale naming APIs#16
shuo-zhou merged 8 commits into
mainfrom
kale-api

Conversation

@shuo-zhou

@shuo-zhou shuo-zhou commented Jul 17, 2026

Copy link
Copy Markdown
Member

Add two APIs embed and predict, which are equivalent to transformer and estimators, for compatibility with the kale library APIs.

Copilot AI left a comment

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.

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.py and kalelinear/predict.py modules that re-export key transformers/estimators via __all__.
  • Update kalelinear/__init__.py to expose embed and predict as 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.

Copilot AI left a comment

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.

Pull request overview

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

Comment thread tests/test_public_api.py Outdated
Comment thread tests/test_public_api.py Outdated

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Copilot AI left a comment

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.

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 imports embed/predict but doesn’t cache the imported module on the package. This means every attribute access (e.g., kalelinear.embed) re-enters __getattr__ and re-calls import_module (even though it returns from sys.modules). Caching the module in globals() 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}'")

Copilot AI left a comment

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.

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

Copilot AI left a comment

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.

🟡 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 the src at 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) via from kalelinear import ..., which will pass even if kalelinear.__getattr__ is broken because the import machinery can load submodules directly. To actually cover the lazy attribute-loading behavior added in kalelinear/__init__.py, add a test that clears the cached attributes/modules and then accesses kalelinear.embed/kalelinear.predict via 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.

Copilot AI left a comment

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.

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

@shuo-zhou
shuo-zhou merged commit efdd6da into main Aug 1, 2026
1 check passed
@shuo-zhou
shuo-zhou deleted the kale-api branch August 1, 2026 13:09
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