Spaces:
Running
Running
File size: 1,610 Bytes
adc9dea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# 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.
|