Closed ranareehanaslam closed 2 months ago
Thanks for your PR, but
Path.cwd()
We don't need to have models inside the ReActor's directory
"last_device" - is very important part as well as other things you cut - they shouldn't be cut
There's no need to simplify this script because it works super correctly and takes into account many nuances which are really necessary for the current version and functionality
"Don't touch what works correctly" - this is a good phrase indeed :)
Key Changes and Optimizations:
Consolidated Import Logic: Simplified how
models_path
is determined by sequentially attempting to import from different modules and falling back to a default path.Simplified Command Execution: Introduced a
run_command
function to reduce redundancy when calling subprocess for pip installations and uninstallations.Enhanced Package Check: Streamlined
is_installed
to optionally check for a minimum version, using thepackaging
library for accurate version comparison.Streamlined Model Download: The download process now directly checks if the model file exists before attempting to download, avoiding unnecessary downloads.
Simplified ONNX Runtime Installation: The
install_ort
function now dynamically selects and installs the appropriate version of ONNX Runtime based on the availability of CUDA and its version.Requirements Installation: The requirements installation process is encapsulated within
install_requirements
, simplifying the main logic and ensuring all dependencies are installed or updated as needed.This optimized script aims to make the installation process more efficient, readable, and maintainable, ensuring that dependencies are correctly managed and the necessary models are downloaded as required.