Skip to content

Move various imports inside methods/functions to load them lazily when initializing the app#449

Draft
Irozuku wants to merge 57 commits intodevelopfrom
refactor/component-import
Draft

Move various imports inside methods/functions to load them lazily when initializing the app#449
Irozuku wants to merge 57 commits intodevelopfrom
refactor/component-import

Conversation

@Irozuku
Copy link
Collaborator

@Irozuku Irozuku commented Feb 5, 2026

Summary

This pull request refactors import statements across multiple component modules to use lazy imports for third-party dependencies. Heavy libraries are now imported only when the relevant functionality is invoked, reducing startup overhead and improving startup initialization time when the application is built and distributed as an .exe.


Type of Change

Check all that apply like this [x]:

  • Backend change
  • Frontend change
  • CI / Workflow change
  • Build / Packaging change
  • Bug fix
  • Documentation

Changes (by file)

  • Component modules (HuggingFace, imbalanced-learn, scikit-learn):
    Moved imports of pyarrow, torch, datasets, transformers, imblearn, sklearn, numpy, and pandas from the module level into methods or constructors to enable lazy loading.
  • Method implementations (get_output_type, _load_model, _process_batch, transform, fit):
    Added local imports so dependencies are loaded only when the corresponding functionality is used.
  • Type annotations and internal state:
    Updated type hints and attribute initialization to remove direct references to lazily imported libraries.

Testing (optional)

  • Verify that affected components still function correctly when executed.
  • Confirm that component modules can be imported without requiring optional dependencies.
  • Check that application startup is faster when running the packaged .exe.

Notes (optional)

This change is especially beneficial for packaged distributions, as it reduces import-time overhead and avoids bundling or loading unused dependencies during application startup.

…type method for lazy loading in LabelEncoder
…azy loading in SelectFwe, SelectKBest, and SelectPercentile
…azy loading in SimpleImputer, SkewedChi2Sampler, and StandardScaler
…azy loading in TruncatedSVD, TFIDFConverter, and VarianceThreshold
…ing in CharacterReplacer, ColumnRemover, and NanRemover
…ading in CSVDataLoader, ExcelDataLoader, and JSONDataLoader
… PartialDependence, and PermutationFeatureImportance
… HammingDistance, LogLoss, and Precision metrics
… ExplainedVariance, MAE, and MedianAbsoluteError metrics
…WordsTextClassificationModel, MLPRegression, and SklearnLikeModel
@Irozuku Irozuku added back Backend work help wanted Extra attention is needed labels Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

back Backend work help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant