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

start splitting kfactory into subpackages #522

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sebastian-goeldi
Copy link
Collaborator

@sebastian-goeldi sebastian-goeldi commented Nov 22, 2024

Summary by Sourcery

Enhancements:

  • Begin modularizing the kfactory package by introducing dynamic imports for 'packing' and 'cells' submodules.

Copy link
Contributor

sourcery-ai bot commented Nov 22, 2024

Reviewer's Guide by Sourcery

This PR implements lazy loading for subpackages in kfactory by modifying the package's init.py file. The implementation uses Python's getattr mechanism to dynamically import 'packing' and 'cells' submodules only when they are first accessed.

Class diagram for kfactory package restructuring

classDiagram
    class kfactory {
        +flexgrid_dbu
        +flexgrid
        +grid_dbu
        +grid
        +constant
        +config
        +dpolygon_from_array
        +kdb
        +lay
        +logger
        +placer
        +polygon_from_array
        +port
        +VInstance
        +VKCell
        +cell
        +__getattr__(name: str) ModuleType | None
    }
    note for kfactory "Lazy loading implemented for 'packing' and 'cells' submodules using __getattr__"
Loading

File-Level Changes

Change Details Files
Implement lazy loading for subpackages using getattr
  • Add getattr function to handle dynamic imports of 'packing' and 'cells' submodules
  • Import required 'types' and 'importlib' modules
  • Remove direct exports of 'cells' and 'packing' from all
src/kfactory/__init__.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.

Comment on lines +59 to +60
if name in ["packing", "cells"]:
return importlib.import_module("." + name, __name__)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): We've found these issues:

Suggested change
if name in ["packing", "cells"]:
return importlib.import_module("." + name, __name__)
if name in {"packing", "cells"}:
return importlib.import_module(f".{name}", __name__)

Copy link

Label error. Requires at least 1 of: breaking, bug, github_actions, documentation, dependencies, enhancement, feature, maintenance, security. Found:

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.

1 participant