|
| 1 | +# Migration Notes: Modernization to 2025 |
| 2 | + |
| 3 | +This document summarizes the modernization work completed on pythonplot.com. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The project has been modernized from 2020-era dependencies and infrastructure to 2025 standards: |
| 8 | +- Python 3.6 → 3.11 |
| 9 | +- Conda → uv package manager |
| 10 | +- Travis CI → GitHub Actions |
| 11 | +- Outdated plotting libraries → Latest versions |
| 12 | +- Deprecated packages removed |
| 13 | + |
| 14 | +## Changes Made |
| 15 | + |
| 16 | +### 1. Python Environment Modernization |
| 17 | + |
| 18 | +**New Files:** |
| 19 | +- `pyproject.toml`: Modern Python project configuration with all dependencies |
| 20 | +- `setup_r.sh`: Script to install R packages (ggplot2, mgcv) |
| 21 | + |
| 22 | +**Updated Files:** |
| 23 | +- `runtime.txt`: 3.6 → 3.11 |
| 24 | +- `requirements.txt`: All packages updated to latest versions with minimum version constraints |
| 25 | + |
| 26 | +**Removed Dependencies:** |
| 27 | +- `altair-saver` → Deprecated, using native altair rendering |
| 28 | +- `chart-studio` → Not needed with plotly v5 local rendering |
| 29 | +- `plotly-orca` → Replaced by Kaleido |
| 30 | +- Duplicate `selenium` entry removed |
| 31 | + |
| 32 | +**Updated Dependencies:** |
| 33 | +| Package | Old Version | New Version | Notes | |
| 34 | +|---------|-------------|-------------|-------| |
| 35 | +| plotly | 4.10.0 | 5.24+ | No authentication needed for local rendering | |
| 36 | +| plotnine | <0.7.0 | 0.13+ | Better ggplot2 compatibility | |
| 37 | +| statsmodels | 0.11.1 | 0.14+ | Security fixes | |
| 38 | +| seaborn | (latest) | 0.13+ | Updated API | |
| 39 | +| altair | (latest) | 5.0+ | Major version bump | |
| 40 | +| rpy2 | (unversioned) | 3.5+ | Python 3.11+ compatible | |
| 41 | +| selenium | (duplicated) | 4.15+ | API changes in v4 | |
| 42 | +| pandas | (latest) | 2.0+ | Major improvements | |
| 43 | +| matplotlib | (latest) | 3.7+ | Modern features | |
| 44 | + |
| 45 | +### 2. R Integration Updates |
| 46 | + |
| 47 | +**Approach:** Separate system R installation (no longer using conda) |
| 48 | + |
| 49 | +**Changes:** |
| 50 | +- Created `setup_r.sh` to install R packages |
| 51 | +- R must be installed separately (via Homebrew, apt, or CRAN) |
| 52 | +- rpy2 updated to work with system R and Python 3.11+ |
| 53 | +- Documentation updated to explain R setup |
| 54 | + |
| 55 | +**Environment Variable:** `R_HOME` must be set correctly for rpy2 to work |
| 56 | + |
| 57 | +### 3. Build System Updates |
| 58 | + |
| 59 | +**Makefile Changes:** |
| 60 | +- Removed `plotly_auth` target (no longer needed) |
| 61 | +- Added `setup` target for uv-based dependency installation |
| 62 | +- Updated `dev_environment` to use uv instead of conda |
| 63 | +- Updated `.PHONY` declarations |
| 64 | + |
| 65 | +**What Didn't Change:** |
| 66 | +- Core build targets (`render`, `qrender`, `test`, `run_nb`) |
| 67 | +- render.py script (compatible with new libraries) |
| 68 | +- Notebook structure and tagging system |
| 69 | + |
| 70 | +### 4. CI/CD Migration |
| 71 | + |
| 72 | +**From:** Travis CI |
| 73 | +**To:** GitHub Actions |
| 74 | + |
| 75 | +**New File:** `.github/workflows/deploy.yml` |
| 76 | + |
| 77 | +**Workflow Features:** |
| 78 | +- Uses r-lib/setup-r for R installation |
| 79 | +- Uses uv for Python dependencies |
| 80 | +- Runs on every push and pull request |
| 81 | +- Automatic Netlify deployment: |
| 82 | + - Production: master branch |
| 83 | + - Preview: all other branches |
| 84 | + |
| 85 | +**Required GitHub Secrets:** |
| 86 | +- `NETLIFY_AUTH_TOKEN` |
| 87 | +- `NETLIFY_SITE_ID` |
| 88 | + |
| 89 | +**Legacy Files (Now Deprecated):** |
| 90 | +- `.travis.yml` |
| 91 | +- `.travis/authenticate_plotly.py` (marked deprecated with explanation) |
| 92 | +- `.travis/install_conda.sh` (wasn't being used) |
| 93 | +- `.travis/invalidate_cloudfront.py` (not needed with Netlify) |
| 94 | + |
| 95 | +### 5. Documentation Updates |
| 96 | + |
| 97 | +**README.md:** |
| 98 | +- Added modern development setup instructions |
| 99 | +- Updated to reflect uv usage |
| 100 | +- Added build and CI/CD sections |
| 101 | +- Clarified plotly no longer needs authentication |
| 102 | + |
| 103 | +**CLAUDE.md:** |
| 104 | +- Updated all dependency versions |
| 105 | +- Documented new setup process |
| 106 | +- Added CI/CD section |
| 107 | +- Updated technical constraints |
| 108 | + |
| 109 | +**New Documentation:** |
| 110 | +- `TESTING_CHECKLIST.md`: Comprehensive testing guide for first build |
| 111 | +- `MIGRATION_NOTES.md`: This file |
| 112 | + |
| 113 | +## Next Steps |
| 114 | + |
| 115 | +### Before First Build |
| 116 | + |
| 117 | +1. **Install System Dependencies:** |
| 118 | + ```bash |
| 119 | + # macOS |
| 120 | + brew install r |
| 121 | + |
| 122 | + # Ubuntu/Debian |
| 123 | + sudo apt-get install r-base r-base-dev |
| 124 | + ``` |
| 125 | + |
| 126 | +2. **Set Up Development Environment:** |
| 127 | + ```bash |
| 128 | + make dev_environment |
| 129 | + ``` |
| 130 | + |
| 131 | +3. **Verify Setup:** |
| 132 | + ```bash |
| 133 | + # Test Python packages |
| 134 | + python -c "import pandas, plotly, seaborn, plotnine, altair, rpy2; print('✓ Python packages OK')" |
| 135 | + |
| 136 | + # Test R integration |
| 137 | + python -c "import rpy2.robjects as ro; ro.r('library(ggplot2)'); print('✓ R integration OK')" |
| 138 | + ``` |
| 139 | + |
| 140 | +### Testing the Build |
| 141 | + |
| 142 | +4. **Run Tests:** |
| 143 | + ```bash |
| 144 | + make test |
| 145 | + ``` |
| 146 | + |
| 147 | +5. **Try Quick Render (no notebook execution):** |
| 148 | + ```bash |
| 149 | + make qrender |
| 150 | + ``` |
| 151 | + |
| 152 | +6. **Full Build (executes notebook):** |
| 153 | + ```bash |
| 154 | + make render |
| 155 | + ``` |
| 156 | + - This will take several minutes |
| 157 | + - Watch for any library compatibility issues |
| 158 | + - Check `TESTING_CHECKLIST.md` for specific things to verify |
| 159 | + |
| 160 | +### Setting Up CI/CD |
| 161 | + |
| 162 | +7. **Configure GitHub Secrets:** |
| 163 | + - Go to your GitHub repo → Settings → Secrets and variables → Actions |
| 164 | + - Add `NETLIFY_AUTH_TOKEN` (from Netlify account settings) |
| 165 | + - Add `NETLIFY_SITE_ID` (from Netlify site settings) |
| 166 | + |
| 167 | +8. **Test GitHub Actions:** |
| 168 | + - Push to a test branch |
| 169 | + - Check Actions tab to see workflow run |
| 170 | + - Verify Netlify preview deployment |
| 171 | + |
| 172 | +9. **Deploy to Production:** |
| 173 | + - Merge to master branch |
| 174 | + - GitHub Actions will automatically deploy to production |
| 175 | + |
| 176 | +## Potential Issues to Watch For |
| 177 | + |
| 178 | +### Library Compatibility |
| 179 | + |
| 180 | +1. **plotly v5 Changes:** |
| 181 | + - API changes from v4 to v5 |
| 182 | + - Different image rendering (Kaleido vs Orca) |
| 183 | + - No authentication needed |
| 184 | + |
| 185 | +2. **altair v5 Changes:** |
| 186 | + - May need updates to save PNG images |
| 187 | + - Selenium/geckodriver integration |
| 188 | + |
| 189 | +3. **plotnine 0.13:** |
| 190 | + - Better ggplot2 compatibility but some API changes |
| 191 | + |
| 192 | +4. **statsmodels 0.14:** |
| 193 | + - Check regression plots and confidence intervals |
| 194 | + |
| 195 | +### Environment Issues |
| 196 | + |
| 197 | +1. **R_HOME:** |
| 198 | + - Must be set correctly for rpy2 |
| 199 | + - GitHub Actions sets this automatically |
| 200 | + - Locally: `export R_HOME=$(R RHOME)` |
| 201 | + |
| 202 | +2. **Headless Rendering:** |
| 203 | + - Selenium needs xvfb on Linux |
| 204 | + - GitHub Actions handles this automatically |
| 205 | + - Locally on Linux: `xvfb-run make render` |
| 206 | + |
| 207 | +3. **geckodriver:** |
| 208 | + - Must be in PATH for selenium |
| 209 | + - GitHub Actions installs this automatically |
| 210 | + - Locally: Install via package manager or download |
| 211 | + |
| 212 | +## Rollback Plan |
| 213 | + |
| 214 | +If you encounter critical issues: |
| 215 | + |
| 216 | +1. **Keep Travis CI temporarily:** |
| 217 | + - Don't delete `.travis.yml` until GitHub Actions is proven |
| 218 | + - Both can run simultaneously |
| 219 | + |
| 220 | +2. **Pin problematic packages:** |
| 221 | + - If specific library versions cause issues, pin to older versions in requirements.txt |
| 222 | + - Example: `plotly==4.14.3` if v5 has problems |
| 223 | + |
| 224 | +3. **Gradual migration:** |
| 225 | + - Update libraries one at a time |
| 226 | + - Test each change thoroughly |
| 227 | + |
| 228 | +## Files Changed Summary |
| 229 | + |
| 230 | +**New Files:** |
| 231 | +- `pyproject.toml` |
| 232 | +- `setup_r.sh` |
| 233 | +- `.github/workflows/deploy.yml` |
| 234 | +- `TESTING_CHECKLIST.md` |
| 235 | +- `MIGRATION_NOTES.md` |
| 236 | + |
| 237 | +**Modified Files:** |
| 238 | +- `runtime.txt` |
| 239 | +- `requirements.txt` |
| 240 | +- `Makefile` |
| 241 | +- `README.md` |
| 242 | +- `CLAUDE.md` |
| 243 | +- `.travis/authenticate_plotly.py` (deprecated with explanation) |
| 244 | + |
| 245 | +**Deprecated (Not Deleted):** |
| 246 | +- `environment.yml` (conda environment - no longer used) |
| 247 | +- `.travis.yml` (Travis CI config) |
| 248 | +- `.travis/` directory (old CI scripts) |
| 249 | + |
| 250 | +**No Changes:** |
| 251 | +- `render.py` (compatible with new libraries) |
| 252 | +- `Examples.ipynb` (may need updates if libraries break examples) |
| 253 | +- `templates/t_index.html` |
| 254 | +- `tests/test_plots.py` |
| 255 | +- `INTRO.md` |
| 256 | + |
| 257 | +## Success Criteria |
| 258 | + |
| 259 | +The migration is successful when: |
| 260 | + |
| 261 | +- [ ] `make dev_environment` completes without errors |
| 262 | +- [ ] `make test` passes all tests |
| 263 | +- [ ] `make render` executes notebook and generates all plots |
| 264 | +- [ ] GitHub Actions workflow runs successfully |
| 265 | +- [ ] Site deploys correctly to Netlify |
| 266 | +- [ ] All plotting libraries render correctly |
| 267 | +- [ ] R ggplot2 examples work via rpy2 |
| 268 | + |
| 269 | +## Support |
| 270 | + |
| 271 | +If you encounter issues: |
| 272 | + |
| 273 | +1. Check `TESTING_CHECKLIST.md` for common problems |
| 274 | +2. Review GitHub Actions logs for CI issues |
| 275 | +3. Check package compatibility in individual notebook cells |
| 276 | +4. File issues in the GitHub repository |
| 277 | + |
| 278 | +--- |
| 279 | + |
| 280 | +**Migration completed:** 2025-11-04 |
| 281 | +**Python version:** 3.11+ |
| 282 | +**Primary changes:** uv adoption, library updates, CI/CD modernization |
0 commit comments