From c2a8a46788b763d8f22d28f4c51c708a661c4ee6 Mon Sep 17 00:00:00 2001 From: Stefanie Molin <24376333+stefmolin@users.noreply.github.com> Date: Sat, 9 Aug 2025 13:55:30 -0400 Subject: [PATCH] Build slides in action --- .github/workflows/publish-slides.yml | 18 +- .gitignore | 1 + pyproject.toml | 5 + slides/README.md | 2 +- slides/generate_slides.sh | 51 +- slides/html/README.md | 3 - slides/html/workshop.slides.html | 128805 ------------------------ uv.lock | 16 +- 8 files changed, 51 insertions(+), 128850 deletions(-) delete mode 100644 slides/html/README.md delete mode 100644 slides/html/workshop.slides.html diff --git a/.github/workflows/publish-slides.yml b/.github/workflows/publish-slides.yml index 1a3af36..43d542e 100644 --- a/.github/workflows/publish-slides.yml +++ b/.github/workflows/publish-slides.yml @@ -21,17 +21,17 @@ concurrency: cancel-in-progress: false jobs: - # Single deploy job since we're just deploying - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} + build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Setup Pages uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 + - name: Install uv + uses: astral-sh/setup-uv@a02a550bdd3185dba2ebb6aa98d77047ce54ad21 # v6.2.1 + - name: Build slides + run: ./slides/generate_slides.sh regular - name: Package files run: | mkdir public && \ @@ -40,6 +40,14 @@ jobs: uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 with: path: public + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/.gitignore b/.gitignore index eebc578..684cf64 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,4 @@ dmypy.json # misc. .DS_Store +slides/html/ diff --git a/pyproject.toml b/pyproject.toml index 590402c..11d8c85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,3 +23,8 @@ dependencies = [ "hvplot==0.9.2", "panel==1.4.2", ] + +[dependency-groups] +slides = [ + "nbmerge>=0.0.4", +] diff --git a/slides/README.md b/slides/README.md index 7469109..555e622 100644 --- a/slides/README.md +++ b/slides/README.md @@ -1,3 +1,3 @@ # Workshop Slides -This directory contains the notebooks used to generate the slides. The HTML version of the slides can be found in the [`html/`](./html/) directory. To generate a PDF version of the slides, use [this](https://stefaniemolin.com/python-data-viz-workshop/?print-pdf#/) link to view the slides (be patient – it takes a while to load), and then use `ctrl + P` or `cmd + P` to print to a PDF file. +This directory contains the notebooks used to generate the slides. The slides themselves can be found at [`stefaniemolin.com/python-data-viz-workshop`](https://stefaniemolin.com/python-data-viz-workshop/). To generate a PDF version of the slides, use [this link instead](https://stefaniemolin.com/python-data-viz-workshop/?print-pdf#/) to view the slides (be patient – it takes a while to load), and then use `ctrl + P` or `cmd + P` to print to a PDF file. diff --git a/slides/generate_slides.sh b/slides/generate_slides.sh index 5022b53..7e093b9 100755 --- a/slides/generate_slides.sh +++ b/slides/generate_slides.sh @@ -1,7 +1,4 @@ -#!/bin/bash - -# setup -VENV_NAME="data_viz_workshop" +#!/usr/bin/env -S uv run --group slides bash # get paths SCRIPT=$(realpath "$0") @@ -14,38 +11,22 @@ if [[ "$#" -ne 1 ]]; then else TEMPLATE_TYPE="$1"; - # get venv status - ACTIVE_ENV=$(basename $CONDA_DEFAULT_ENV) - - if [[ "$CONDA_DEFAULT_ENV" == "" ]]; then - echo "Virtual environment is not enabled. Quitting..."; - else - if [[ "$CONDA_DEFAULT_ENV" != "$VENV_NAME" ]]; then - echo "The $VENV_NAME conda env is not activated."; - else - # if nbmerge isn't installed, do so - echo "Checking for nbmerge..." - pip3 freeze | grep nbmerge || pip3 install nbmerge; - - # use nbmerge to combine all slide notebooks into a single notebook - echo "[nbmerge] Creating a combined notebook for all slides..." - COMBINED_NOTEBOOK="$SLIDES_DIR/workshop.ipynb" - nbmerge -o $COMBINED_NOTEBOOK $SLIDES_DIR/*.ipynb; - - # make all slide decks - jupyter nbconvert \ - --to slides \ - --template=$TEMPLATE_TYPE \ - --TemplateExporter.extra_template_basedirs="$SLIDES_DIR"/templates \ - --output-dir="$SLIDES_DIR"/html \ - "$COMBINED_NOTEBOOK"; + # use nbmerge to combine all slide notebooks into a single notebook + echo "[nbmerge] Creating a combined notebook for all slides..." + COMBINED_NOTEBOOK="$SLIDES_DIR/workshop.ipynb" + nbmerge -o $COMBINED_NOTEBOOK $SLIDES_DIR/*.ipynb; - # delete the combined notebook - echo "Cleaning up..." - rm $COMBINED_NOTEBOOK + # make all slide decks + jupyter nbconvert \ + --to slides \ + --template=$TEMPLATE_TYPE \ + --TemplateExporter.extra_template_basedirs="$SLIDES_DIR"/templates \ + --output-dir="$SLIDES_DIR"/html \ + "$COMBINED_NOTEBOOK"; - echo "Done!"; - fi - fi + # delete the combined notebook + echo "Cleaning up..." + rm $COMBINED_NOTEBOOK + echo "Done!"; fi diff --git a/slides/html/README.md b/slides/html/README.md deleted file mode 100644 index 1d01a65..0000000 --- a/slides/html/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Workshop Slides - -This directory contains the HTML slides, which can be viewed in your browser. The complete slide deck is [here](workshop.slides.html). diff --git a/slides/html/workshop.slides.html b/slides/html/workshop.slides.html deleted file mode 100644 index 4b158c1..0000000 --- a/slides/html/workshop.slides.html +++ /dev/null @@ -1,128805 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Beyond the Basics: Data Visualization in Python workshop slides | Stefanie Molin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
-
-
-
-
-
-
-
-
- -
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- -
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
- -
- -
-
- -
-
-
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
- -
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
- -
-
- -
-
- -
-
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
- - - - - - - - - - - diff --git a/uv.lock b/uv.lock index bf542c9..1ef44ea 100644 --- a/uv.lock +++ b/uv.lock @@ -1079,7 +1079,7 @@ name = "importlib-metadata" version = "8.7.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "zipp", marker = "python_full_version < '3.10'" }, + { name = "zipp", marker = "python_full_version < '3.11'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/76/66/650a33bd90f786193e4de4b3ad86ea60b53c89b669a5c7be931fac31cdb0/importlib_metadata-8.7.0.tar.gz", hash = "sha256:d13b81ad223b890aa16c5471f2ac3056cf76c5f10f82d6f9292f0b415f389000", size = 56641, upload-time = "2025-04-27T15:29:01.736Z" } wheels = [ @@ -1927,6 +1927,12 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/a9/82/0340caa499416c78e5d8f5f05947ae4bc3cba53c9f038ab6e9ed964e22f1/nbformat-5.10.4-py3-none-any.whl", hash = "sha256:3b48d6c8fbca4b299bf3982ea7db1af21580e4fec269ad087b9e81588891200b", size = 78454, upload-time = "2024-04-04T11:20:34.895Z" }, ] +[[package]] +name = "nbmerge" +version = "0.0.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/73/a9/56a02f2a3405397af9924e1d372b2e546ebcdb312d800f3945b321a328a5/nbmerge-0.0.4.tar.gz", hash = "sha256:f432797ee685ed495a2daa4dbb76e2b52028d2c3a38142b523bb5cb832df0882", size = 7590, upload-time = "2017-05-14T21:14:22.954Z" } + [[package]] name = "nest-asyncio" version = "1.6.0" @@ -2435,6 +2441,11 @@ dependencies = [ { name = "shapely" }, ] +[package.dev-dependencies] +slides = [ + { name = "nbmerge" }, +] + [package.metadata] requires-dist = [ { name = "bokeh", specifier = "==3.4.1" }, @@ -2452,6 +2463,9 @@ requires-dist = [ { name = "shapely", specifier = "==2.0.4" }, ] +[package.metadata.requires-dev] +slides = [{ name = "nbmerge", specifier = ">=0.0.4" }] + [[package]] name = "python-dateutil" version = "2.9.0.post0"