# ClosedToOpen Recipe Generator This script converts Jupyter notebooks to recipe pages using [nbgradio](https://github.com/gradio-app/nbgradio). ## Usage ### Using uv (Recommended) ```bash uv run generate_recipes.py ``` ### Direct execution ```bash ./generate_recipes.py ``` ## What it does 1. **Scans notebooks**: Finds all `.ipynb` files in the `notebooks/` directory 2. **Updates notebooks**: Adds `#nbgradio` comments to cells containing Gradio code 3. **Converts to recipes**: Uses nbgradio with `--spaces` and `--fragment` flags to generate HTML 4. **Creates recipe pages**: Wraps the generated content in the blog's styling 5. **Deploys to Spaces**: Automatically deploys Gradio apps to Hugging Face Spaces ## Features - **Automatic dependency management**: Uses uv's inline script metadata - **Spaces integration**: Deploys interactive apps to Hugging Face Spaces - **Blog integration**: Generates pages that match the site's design - **Incremental updates**: Skips notebooks that already have recipes - **Error handling**: Graceful handling of conversion failures ## Requirements - Python 3.10+ - uv package manager - Hugging Face account (for Spaces deployment) ## Generated Files - `recipes/{notebook_name}.html` - Complete recipe pages - Interactive Gradio apps deployed to Hugging Face Spaces - Proper styling integration with the main blog ## Script Dependencies The script uses uv's inline metadata format to declare dependencies: ```python # /// script # dependencies = [ # "nbgradio", # ] # /// ``` This ensures nbgradio is automatically installed when running the script.