Move various imports inside methods/functions to load them lazily when initializing the app#449
Draft
Move various imports inside methods/functions to load them lazily when initializing the app#449
Conversation
…oved laziness in sklearn wrapper.
…mbedding converter
…okenizer converter
…n SMOTEENNConverter
…azy loading in AdditiveChi2Sampler
…lazy loading in BagOfWordsConverter
…azy loading in Binarizer
…azy loading in CCA
…azy loading in FastICA
…azy loading in GenericUnivariateSelect
…azy loading in KNNImputer
…azy loading in LabelBinarizer
…type method for lazy loading in LabelEncoder
…azy loading in MaxAbsScaler
…azy loading in MinMaxScaler
…azy loading in MissingIndicator
…azy loading in Normalizer
…azy loading in Nystroem
…azy loading in OneHotEncoder
…azy loading in PCA
…azy loading in PolynomialFeatures
…azy loading in RBFSampler
…azy loading in SelectFdr
…azy loading in SelectFpr
…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
…ading in BaseDataLoader
… PartialDependence, and PermutationFeatureImportance
…arnings in GenerativeJob
… accuracy, cohen_kappa, and f1 metrics
… HammingDistance, LogLoss, and Precision metrics
… Recall and ROCAUC metrics
… ExplainedVariance, MAE, and MedianAbsoluteError metrics
… MSE, R2, and RMSE metrics
… BLEU, CHRF, and TER metrics
…WordsTextClassificationModel, MLPRegression, and SklearnLikeModel
…l dependencies in DashAIDataset file
…global scope in utils.py
…shai_dataset.py and corr_matrix.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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]:
Changes (by file)
Moved imports of
pyarrow,torch,datasets,transformers,imblearn,sklearn,numpy, andpandasfrom the module level into methods or constructors to enable lazy loading.get_output_type,_load_model,_process_batch,transform,fit):Added local imports so dependencies are loaded only when the corresponding functionality is used.
Updated type hints and attribute initialization to remove direct references to lazily imported libraries.
Testing (optional)
.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.