This workflow automatically updates the requirements.txt file based on Python imports found in Jupyter notebooks across the repository.
The workflow runs on:
- Push to main: When notebooks (
.ipynbfiles) are modified - Pull requests: When notebooks are modified
- Schedule: Weekly on Mondays at 00:00 UTC
- Manual: Can be triggered manually via workflow dispatch
- Scans all subdirectories for Jupyter notebooks (
.ipynbfiles) - Extracts Python import statements from code cells
- Maps import names to PyPI package names (e.g.,
sklearn→scikit-learn) - Generates an updated
requirements.txtfile with all unique packages - Creates a pull request if changes are detected
The main logic is in .github/scripts/update_requirements.py, which:
- Recursively finds all notebooks
- Parses notebook JSON to extract imports
- Filters out standard library modules
- Handles common package name mappings
- Outputs a sorted list of dependencies