mirror of
https://github.com/NVIDIA-NeMo/DataDesigner
synced 2026-05-24 09:48:29 +00:00
* docs: prepare fern generated artifacts * docs: update fern migration artifacts * docs: leave colab notebooks unchanged * docs: add VLM recipe cards to Fern * docs: trim Dev Notes sidebar * docs: collapse older Dev Notes in sidebar * docs: add Fern publishing workflows * docs: gate Fern publishing on check * docs: restrict hosted previews for fork PRs * docs: clean Fern preview URL * docs: cancel stale preview runs * docs: clarify devnotes notebook reuse * docs: clean older versions route * docs: document Fern versioning conventions * docs: add Fern release version guard * docs: harden Fern release tag handling * ci: let docs preview continue after fern failure * ci: split docs preview deploy * docs: clarify fern make commands * ci: harden fern deploy workflows * docs: render preview notebooks without outputs * ci: keep docs preview deploy inline * docs: align notebook code highlighting * docs: show notebook snippet scrollbars * docs: isolate fern preview check failures * ci: align fern release docs behavior
71 lines
2.2 KiB
Bash
Executable file
71 lines
2.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Build notebooks with per-file caching. Only re-executes notebooks whose
|
|
# source .py file changed since the last cached build.
|
|
#
|
|
# Usage:
|
|
# ./docs/scripts/build_notebooks_cached.sh [CACHE_DIR]
|
|
#
|
|
# CACHE_DIR defaults to .notebook-cache
|
|
|
|
set -euo pipefail
|
|
|
|
compute_sha256() {
|
|
if command -v sha256sum >/dev/null 2>&1; then
|
|
sha256sum "$1" | cut -d' ' -f1
|
|
else
|
|
shasum -a 256 "$1" | cut -d' ' -f1
|
|
fi
|
|
}
|
|
|
|
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
SOURCE_DIR="$REPO_ROOT/docs/notebook_source"
|
|
OUTPUT_DIR="$REPO_ROOT/docs/notebooks"
|
|
CACHE_DIR="${1:-$REPO_ROOT/.notebook-cache}"
|
|
DOCS_JUPYTEXT="${DOCS_JUPYTEXT:-$REPO_ROOT/.venv/bin/jupytext}"
|
|
|
|
if [ ! -x "$DOCS_JUPYTEXT" ]; then
|
|
echo "❌ Missing jupytext executable: $DOCS_JUPYTEXT"
|
|
echo "Run 'make install-dev-notebooks' first."
|
|
exit 1
|
|
fi
|
|
|
|
rm -rf "$OUTPUT_DIR"
|
|
mkdir -p "$OUTPUT_DIR" "$CACHE_DIR"
|
|
|
|
# Copy static files
|
|
cp "$SOURCE_DIR/_README.md" "$OUTPUT_DIR/README.md"
|
|
cp "$SOURCE_DIR/_pyproject.toml" "$OUTPUT_DIR/pyproject.toml"
|
|
|
|
needs_cleanup=false
|
|
|
|
for src in "$SOURCE_DIR"/*.py; do
|
|
name="$(basename "$src" .py)"
|
|
hash="$(compute_sha256 "$src")"
|
|
cached_hash_file="$CACHE_DIR/${name}.sha256"
|
|
cached_notebook="$CACHE_DIR/${name}.ipynb"
|
|
|
|
if [ -f "$cached_hash_file" ] && [ -f "$cached_notebook" ] && [ "$(cat "$cached_hash_file")" = "$hash" ]; then
|
|
echo " ✅ $name.ipynb - cached (unchanged)"
|
|
cp "$cached_notebook" "$OUTPUT_DIR/${name}.ipynb"
|
|
else
|
|
echo " 🔄 $name.ipynb - executing..."
|
|
"$DOCS_JUPYTEXT" --to ipynb --execute "$src"
|
|
mv "$SOURCE_DIR/${name}.ipynb" "$OUTPUT_DIR/${name}.ipynb"
|
|
needs_cleanup=true
|
|
|
|
# Update cache
|
|
cp "$OUTPUT_DIR/${name}.ipynb" "$cached_notebook"
|
|
echo "$hash" > "$cached_hash_file"
|
|
fi
|
|
done
|
|
|
|
if [ "$needs_cleanup" = true ]; then
|
|
# Clean up artifacts from executed notebooks
|
|
[ -d "$SOURCE_DIR/artifacts" ] && rm -rf "$SOURCE_DIR/artifacts"
|
|
find "$SOURCE_DIR" -name '*.csv' -delete 2>/dev/null || true
|
|
fi
|
|
|
|
echo "✅ Notebooks ready in $OUTPUT_DIR"
|