feat: Add Python 3.10 compatibility and modern library support #2187
+629
−41
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.
Overview
This PR adds comprehensive Python 3.10 compatibility and modernizes RecBole to work with current library versions, addressing multiple compatibility issues that prevent RecBole from running in modern Python environments.
Changes Made
🔧 Core Compatibility Fixes
numpy 2.0 compatibility: Fixed deprecated type aliases (
np.float_,np.int_,np.bool_,np.long_)recbole/config/configurator.pywith conditional compatibility settingsrecbole/evaluator/metrics.pydtype specificationsrecbole/trainer/hyper_tuning.pyandrecbole/model/layers.pyscipy compatibility: Fixed removed
dok_matrix._update()methodPyTorch 2.6 compatibility: Fixed
torch.load()weights_only parameterweights_only=Falsefor full model checkpoint loadingray tune optimization: Implemented lazy import to avoid dependency conflicts
🐳 Infrastructure Improvements
docker-compose.ymlfor easy development workflow.gitignoreand added.dockerignoreTesting
Backward Compatibility
All changes maintain full backward compatibility while enabling use with modern Python 3.10 and latest library versions.
Impact
Related Issues
Addresses compatibility issues with modern Python environments that currently prevent RecBole from running on Python 3.10+.
Note: This PR includes comprehensive testing and maintains all existing functionality while adding modern compatibility support.
概覽
此 PR 新增了完整的 Python 3.10 相容性,並將 RecBole 現代化以支援最新的函式庫版本,解決了多個相容性問題,使 RecBole 能在現代 Python 環境中正常運行。
修改內容
🔧 核心相容性修正
numpy 2.0 相容性:修復了已棄用的型別別名(
np.float_、np.int_、np.bool_、np.long_)recbole/config/configurator.py中新增條件式相容性設定recbole/evaluator/metrics.py的 dtype 規範recbole/trainer/hyper_tuning.py與recbole/model/layers.pyscipy 相容性:修正已移除的
dok_matrix._update()方法PyTorch 2.6 相容性:修正
torch.load()的weights_only參數weights_only=False以支援完整模型檢查點載入ray tune 優化:實作 lazy import 以避免相依性衝突
🐳 基礎架構改善
docker-compose.yml以簡化開發流程.gitignore並新增.dockerignore測試
向下相容性
所有修改皆維持完整的向下相容性,同時允許在 Python 3.10 與最新函式庫版本下使用。
影響
相關議題
解決了現代 Python 環境的相容性問題,目前這些問題會阻止 RecBole 在 Python 3.10+ 上執行。
注意:此 PR 已包含完整測試,並在維持所有既有功能的同時,新增了對現代環境的相容性支援。