Move various imports inside methods/functions to load them lazily when initializing the app#449
Open
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
…s and test_execute_jobs
…nd improving initialization
…plifying sampler assignment
… improved perfomance
…and reduce runtime import overhead.
…e for improved startup perfomarnce
…r better performance
…or better performance
…eline_job, and predict_job modules for better performance
…in kernel_shap module
…dules for enhanced performance
…e_converter module for better performance
…umn_remover module for better performance
… improved performance
…onverters for enhanced performance
…edding and tokenizer modules for better performance
…_of_words and label_encoder modules for better performance
…idf and character_replacer modules for better performance
…_remover module for better performance
…oration, prediction, retrieve_model, and train modules for enhanced performance
…n data_selector_node module
…mer and opus_mt_en_es_transformer modules for better performance
…s for consistency
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.