Skip to content

Conversation

@tamio0800
Copy link

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_)

    • Updated recbole/config/configurator.py with conditional compatibility settings
    • Fixed recbole/evaluator/metrics.py dtype specifications
    • Updated recbole/trainer/hyper_tuning.py and recbole/model/layers.py
  • scipy compatibility: Fixed removed dok_matrix._update() method

    • Added fallback implementation for 7 graph neural network models:
    • NGCF, LightGCN, NCL, GCMC, SpectralCF, KGIN, MCCLK
  • PyTorch 2.6 compatibility: Fixed torch.load() weights_only parameter

    • Updated 8 files including trainer, quick_start, and pretrained models
    • Added weights_only=False for full model checkpoint loading
  • ray tune optimization: Implemented lazy import to avoid dependency conflicts

    • Moved import inside function to prevent unnecessary loading

🐳 Infrastructure Improvements

  • Added complete Docker environment with Python 3.10 support
  • Added docker-compose.yml for easy development workflow
  • Added comprehensive troubleshooting guide
  • Updated .gitignore and added .dockerignore

Testing

  • ✅ Verified model training, saving, loading, and inference
  • ✅ Tested multiple model types: general, sequential, knowledge-aware
  • ✅ Confirmed evaluation metrics calculation works correctly
  • ✅ All existing functionality preserved

Backward Compatibility

All changes maintain full backward compatibility while enabling use with modern Python 3.10 and latest library versions.

Impact

  • Enables RecBole to run on Python 3.10+ environments
  • Supports modern versions of numpy (2.x), scipy (1.15+), PyTorch (2.6+)
  • Provides Docker environment for consistent development
  • No breaking changes to existing API

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.pyrecbole/model/layers.py
  • scipy 相容性:修正已移除的 dok_matrix._update() 方法

    • 為 7 個圖神經網路模型新增 fallback 實作:
    • NGCF、LightGCN、NCL、GCMC、SpectralCF、KGIN、MCCLK
  • PyTorch 2.6 相容性:修正 torch.load()weights_only 參數

    • 更新了包含 trainer、quick_start、以及預訓練模型在內的 8 個檔案
    • 新增 weights_only=False 以支援完整模型檢查點載入
  • ray tune 優化:實作 lazy import 以避免相依性衝突

    • 將 import 移至函式內,避免不必要的載入

🐳 基礎架構改善

  • 新增完整的 Docker 環境,支援 Python 3.10
  • 新增 docker-compose.yml 以簡化開發流程
  • 新增完整的疑難排解指南
  • 更新 .gitignore 並新增 .dockerignore

測試

  • ✅ 驗證模型訓練、儲存、載入與推論
  • ✅ 測試多種類型模型:一般型、序列型、知識感知型
  • ✅ 確認評估指標計算正確
  • ✅ 所有既有功能皆維持不變

向下相容性

所有修改皆維持完整的向下相容性,同時允許在 Python 3.10 與最新函式庫版本下使用。

影響

  • 使 RecBole 能在 Python 3.10+ 環境中執行
  • 支援 numpy (2.x)、scipy (1.15+)、PyTorch (2.6+) 最新版本
  • 提供一致性的 Docker 開發環境
  • 對既有 API 無破壞性變更

相關議題

解決了現代 Python 環境的相容性問題,目前這些問題會阻止 RecBole 在 Python 3.10+ 上執行。


注意:此 PR 已包含完整測試,並在維持所有既有功能的同時,新增了對現代環境的相容性支援。

Add comprehensive Docker environment and fix compatibility issues
for modern Python/library versions.

- Add Docker environment with Python 3.10 support
- Add docker-compose.yml for easy development workflow
- Add comprehensive troubleshooting guide and documentation
- Add test scripts for environment validation

- Fix numpy 2.0 compatibility issues (4 files affected)
  * Replace deprecated np.float_, np.int_, np.bool_, np.long_ aliases
  * Update configurator.py, metrics.py, hyper_tuning.py, layers.py

- Fix scipy dok_matrix._update compatibility (7 models affected)
  * Add fallback for removed _update method in newer scipy versions
  * Affects NGCF, LightGCN, NCL, GCMC, SpectralCF, KGIN, MCCLK

- Fix PyTorch 2.6 torch.load compatibility (8 files affected)
  * Add weights_only=False for full model checkpoint loading
  * Update trainer.py, quick_start.py, and 6 pretrained models

- Fix ray tune import conflicts
  * Implement lazy import to avoid unnecessary dependencies

- Add .dockerignore for optimized Docker builds
- Update .gitignore to exclude Docker-related files
- Use editable install (pip install -e .) for development workflow
- Add volume mounts for real-time code changes

- Verify model training, saving, loading, and inference
- Test multiple model types: general, sequential, knowledge-aware
- Confirm evaluation metrics calculation works correctly

All changes maintain backward compatibility while enabling use
with modern Python 3.10 and latest library versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants