Skip to content

Commit 58ea0a5

Browse files
committed
Update Makefile and CLAUDE.md for the uv/GitHub Actions build
1 parent 36a79c9 commit 58ea0a5

2 files changed

Lines changed: 31 additions & 99 deletions

File tree

CLAUDE.md

Lines changed: 30 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ The site is generated from a Jupyter notebook (Examples.ipynb) that contains tag
1515
3. Generates static HTML using Jinja2 templates
1616
4. Outputs PNG images and an HTML file to the `web/` directory
1717

18+
The checked-in Examples.ipynb has no outputs; the site can only be rendered from an executed copy of the notebook.
19+
1820
### Key Components
1921

2022
- **Examples.ipynb**: Source notebook containing plot examples for each library
@@ -24,7 +26,7 @@ The site is generated from a Jupyter notebook (Examples.ipynb) that contains tag
2426
- Parses cell source code and optional markdown comments
2527
- Renders the final HTML using Jinja2
2628
- **templates/t_index.html**: Jinja2 template for the website
27-
- **web/**: Output directory for generated site
29+
- **web/**: Output directory for generated site; web/css/ (checked in) holds custom.css and pygments-native.css
2830
- **INTRO.md**: Markdown content for the site introduction
2931

3032
### Cell Tagging System
@@ -37,40 +39,32 @@ name:scatter-plot # Maps to names dict in render.py
3739
package:seaborn # Maps to packages dict in render.py
3840
```
3941

40-
Valid plot names and packages are defined in dictionaries at the top of render.py (lines 19-43).
42+
Valid plot names and packages are defined in dictionaries at the top of render.py.
4143

4244
## Development Commands
4345

4446
### Setup Environment
4547

4648
```bash
47-
make dev_environment # Installs Python and R dependencies using uv
48-
make setup # Alternative command (same as dev_environment)
49+
make setup # uv sync, Chrome for Kaleido, R packages
4950
```
5051

5152
**Prerequisites:**
52-
- Python 3.11+ installed on system
5353
- R 4.0+ installed separately (via Homebrew, apt, or CRAN)
54-
- uv package manager (auto-installed by make targets if missing)
54+
- uv package manager (auto-installed by make targets if missing; uv provides Python)
5555

5656
**Manual Setup:**
5757
```bash
58-
# Install uv
59-
curl -LsSf https://astral.sh/uv/install.sh | sh
60-
61-
# Install Python dependencies
62-
uv pip install -r requirements.txt
63-
64-
# Install R packages (ggplot2, mgcv)
65-
./setup_r.sh
58+
uv sync # Python dependencies (pyproject.toml + uv.lock)
59+
uv run kaleido_get_chrome # Chrome for plotly PNG export
60+
./setup_r.sh # R packages (ggplot2, mgcv)
6661
```
6762

6863
### Build Site
6964

7065
```bash
71-
make qrender # Quick render from Examples.ipynb without executing
72-
make render # Full build: execute notebook, then render (creates timestamped .ipynb)
73-
make # Full build + S3 upload
66+
make qrender # Render from an already-executed Examples.ipynb (fails if outputs are stripped)
67+
make render # Full build: execute notebook, then render (creates git-hash-stamped .ipynb)
7468
```
7569

7670
The render process:
@@ -83,10 +77,9 @@ The render process:
8377

8478
```bash
8579
make test # Run pytest tests
86-
python -m pytest tests/
8780
```
8881

89-
The test suite (tests/test_plots.py) validates that Examples.ipynb contains all expected plot/package combinations defined in the defined_plots dictionary.
82+
The test suite (tests/test_plots.py) validates that Examples.ipynb contains all expected plot/package tag combinations. It reads tags only, so it works on the outputs-stripped notebook.
9083

9184
### Local Development
9285

@@ -98,12 +91,10 @@ cd web && python -m http.server
9891

9992
### Image Rendering
10093

101-
All plots are rendered to static PNG images:
102-
- **Plotly**: Uses Kaleido for local rendering (no authentication required with v5+)
103-
- **Altair**: Uses native rendering or selenium/geckodriver
104-
- **R/ggplot2**: Uses rpy2 to interface with system R installation
105-
106-
**Note**: Plotly authentication is no longer needed with plotly v5+. The old authentication code in `.travis/authenticate_plotly.py` is deprecated.
94+
All plots are rendered to static PNG images inside the executed notebook:
95+
- **Plotly**: `pio.renderers.default = "png"` with Kaleido (needs Chrome; `uv run kaleido_get_chrome`)
96+
- **Altair**: `alt.renderers.enable("png")` with vl-convert-python (set in the notebook's first cell — do not remove)
97+
- **R/ggplot2**: rpy2 against the system R installation (`%%R` cell magic)
10798

10899
## Adding New Plots
109100

@@ -113,74 +104,30 @@ All plots are rendered to static PNG images:
113104
4. Keep code lines under ~46 characters to avoid horizontal scrolling in the UI
114105
5. Optionally add a markdown comment in triple quotes on the first line
115106
6. Update tests/test_plots.py to include the new plot in defined_plots
116-
7. Run `make qrender` to test (or `make render` for full rebuild)
107+
7. Run `make render` and inspect web/index.html
117108

118109
## Technical Constraints
119110

120111
- Plot code must generate PNG output in the notebook cell
121-
- For plotly, images must be generated via their server (requires credentials)
122112
- R code cells must start with `%%R` magic command
123-
- Altair cells must start with `%%altair` magic command
124113
- Code lines should wrap to ~46 characters for proper display
125114
- All image paths are MD5 hashes of the base64-encoded PNG data
126115

127116
## Dependencies
128117

129-
### Python Environment
130-
- **Python**: 3.11+ (specified in runtime.txt and pyproject.toml)
131-
- **Package Manager**: uv (modern, fast alternative to pip)
132-
- **Jupyter**: For notebook execution
133-
134-
### Plotting Libraries (all latest versions)
135-
- pandas 2.0+
136-
- matplotlib 3.7+
137-
- seaborn 0.13+
138-
- plotnine 0.13+
139-
- plotly 5.24+ (with Kaleido for image export)
140-
- altair 5.0+
141-
- statsmodels 0.14+
142-
143-
### R Environment
144-
- **R**: 4.0+ (system installation required)
145-
- **R Packages**: ggplot2, mgcv
146-
- **Python-R Bridge**: rpy2 3.5+
147-
148-
### Other Key Dependencies
149-
- Jinja2 with jinja2-highlight for templating
150-
- selenium 4.15+ with geckodriver for browser automation
151-
- markdown for text processing
152-
153-
**Configuration Files:**
154-
- `pyproject.toml`: Modern Python project metadata and dependencies
155-
- `requirements.txt`: Pin-free dependency list
156-
- `setup_r.sh`: R package installation script
118+
Python dependencies are declared in `pyproject.toml` and locked in `uv.lock` (committed). Key libraries: pandas, matplotlib, seaborn, plotnine, plotly (+kaleido), altair (+vl-convert-python), statsmodels, rpy2, Jinja2 with jinja2-highlight.
119+
120+
R (system install) with ggplot2 and mgcv, installed by `setup_r.sh`.
157121

158122
## CI/CD
159123

160-
The project uses **GitHub Actions** for continuous integration and deployment (migrated from Travis CI).
161-
162-
### Workflow (.github/workflows/deploy.yml)
163-
164-
**On Every Push:**
165-
1. Setup R 4.3 using r-lib/setup-r action
166-
2. Install R packages (ggplot2, mgcv)
167-
3. Setup Python 3.11
168-
4. Install uv and Python dependencies
169-
5. Setup Firefox and geckodriver for selenium
170-
6. Run pytest tests with xvfb (virtual display)
171-
7. Execute notebook and render site
172-
8. Deploy to Netlify:
173-
- **master branch**: Production deployment
174-
- **Other branches**: Preview deployments
175-
176-
**Required Secrets:**
177-
- `NETLIFY_AUTH_TOKEN`: Netlify authentication token
178-
- `NETLIFY_SITE_ID`: Netlify site identifier
179-
180-
**Environment Variables:**
181-
- `R_HOME`: Set to R installation path (e.g., `/opt/R/4.3.3/lib/R` on GitHub runners)
182-
183-
### Legacy CI Files
184-
- `.travis.yml`: Old Travis CI config (deprecated)
185-
- `.travis/`: Old CI scripts (mostly deprecated)
186-
- `.travis/authenticate_plotly.py`: No longer needed with plotly v5+
124+
GitHub Actions (`.github/workflows/deploy.yml`) on every push:
125+
126+
1. Setup R (r-lib/actions, RSPM binary packages) and install ggplot2/mgcv
127+
2. Install uv (astral-sh/setup-uv with caching) and `uv sync`
128+
3. `uv run kaleido_get_chrome`
129+
4. Run pytest
130+
5. Execute notebook and render site
131+
6. Deploy to Netlify: production on master pushes, preview otherwise
132+
133+
**Required Secrets:** `NETLIFY_AUTH_TOKEN`, `NETLIFY_SITE_ID`

Makefile

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
GIT_COMMIT=$(shell git log -1 --pretty=format:"%h")
22
OUTPUTDIR=web
33

4-
S3_BUCKET=pythonplot.com
5-
64
all: render
75

8-
deploy: render s3_upload
9-
106
clean:
117
rm -f Examples.*.ipynb
128
rm -f *.pyc
139
rm -f .Rhistory
1410
rm -f .setup_done
1511

16-
travis: render
17-
1812
.setup_done:
1913
@echo "Setting up development environment..."
2014
@echo "1. Installing Python dependencies with uv..."
@@ -38,19 +32,10 @@ qrender: .setup_done
3832
render: .setup_done run_nb
3933
uv run python render.py "Examples.$(GIT_COMMIT).ipynb"
4034

41-
s3_upload:
42-
s3cmd sync $(OUTPUTDIR)/ s3://$(S3_BUCKET) --acl-public --delete-removed --guess-mime-type --no-mime-magic --no-preserve
43-
4435
run_nb: .setup_done
4536
uv run jupyter nbconvert --to notebook --execute "Examples.ipynb" --output "Examples.$(GIT_COMMIT).ipynb"
4637

4738
dev_environment: setup
4839
@echo "Development environment ready!"
49-
@echo ""
50-
@echo "Note: This project now uses uv instead of conda."
51-
@echo "R must be installed separately on your system."
52-
53-
cloudfront_invalidate:
54-
python .travis/invalidate_cloudfront.py
5540

56-
.PHONY: all deploy qrender render s3_upload run_nb travis clean cloudfront_invalidate test dev_environment setup
41+
.PHONY: all qrender render run_nb clean test dev_environment setup

0 commit comments

Comments
 (0)