Skip to content

chore(scripts): render cli_interactive tapes in parallel - #2010

Draft
bearomorphism wants to merge 1 commit into
masterfrom
script-parallel-filter
Draft

chore(scripts): render cli_interactive tapes in parallel#2010
bearomorphism wants to merge 1 commit into
masterfrom
script-parallel-filter

Conversation

@bearomorphism

@bearomorphism bearomorphism commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Description

Follow-up to PR #2009 (deterministic gif regeneration) that makes local iteration faster:

  1. Parallelism in scripts/gen_cli_interactive_gifs.py. Tapes now render through a ThreadPoolExecutor with the default capped at min(len(tapes), 4); -j N overrides. Errors are reported per tape with a final summary instead of aborting on the first failure. The poe task doc:screenshots still calls gen_cli_interactive_gifs() with no args (zero-arg compatible signature), so nothing changes for the standard render everything path.

  2. Per-tape workdir in shared/base.tape + shared/cleanup.tape. Both files used to hardcode /tmp/commitizen-example, which would race once multiple tapes ran concurrently. Replaced with mktemp -d "${TMPDIR:-/tmp}/commitizen-example.XXXXXX" saved in a per-tape $WORKDIR shell variable and cleaned up at the end. Rendered gifs are unchanged (the setup runs inside Hide).

Checklist

Was generative AI tooling used to co-author this PR?

  • Yes (please specify the tool below)

Generated-by: GitHub Copilot CLI (claude-opus-4.7-1m-internal) following the guidelines

Code Changes

Expected Behavior

  • uv run poe doc:screenshots continues to render all five interactive gifs (now in parallel, with the same outputs).
  • python scripts/gen_cli_interactive_gifs.py [-j N] renders all tapes with up to N parallel workers (default min(len(tapes), 4)).
  • Parallel runs no longer race on a shared workdir, because each tape now operates in its own mktemp -d directory.

Steps to Test This Pull Request

# Lint
uv run poe lint

# Argparse
python scripts/gen_cli_interactive_gifs.py --help

# Tape syntax still valid
cd docs/images && vhs validate bump.tape commit.tape init.tape shortcut_default.tape shortcut_custom.tape

# (optional, Linux/WSL) End-to-end render
uv run python scripts/gen_cli_interactive_gifs.py        # all 5 in parallel
uv run python scripts/gen_cli_interactive_gifs.py -j 1   # serial
uv run poe doc:screenshots                               # poe task still works

Additional Context

Depends conceptually on but does not require PR #2009 (deterministic gifs). The two PRs touch disjoint files except for shared/base.tape and shared/cleanup.tape, which only PR B modifies.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Commitizen bump preview

Merging this PR will produce the following bump:

bump: version 4.16.3 → 4.17.0
tag to create: v4.17.0
increment detected: MINOR
@bearomorphism
bearomorphism force-pushed the script-parallel-filter branch from b274aaa to fc38683 Compare May 30, 2026 07:07
@bearomorphism bearomorphism changed the title feat(scripts): parallel + filterable cli_interactive gif rendering May 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Commitizen bump preview

No commits in this PR are eligible for a version bump.

@bearomorphism
bearomorphism force-pushed the script-parallel-filter branch from fc38683 to 68fadd8 Compare May 30, 2026 07:23
@bearomorphism

Copy link
Copy Markdown
Collaborator Author

Slimmer rewrite at 68fadd8: PR diff dropped from +151/-29 to +100/-29 by inlining helpers (_render_one, _resolve_tapes, _default_workers, _build_parser, main) and replacing the CPU-aware worker default with min(len(tapes), 4). Public gen_cli_interactive_gifs(tape_names=None, max_workers=None) signature, CLI flags, preflight VHS check, and per-tape error reporting are unchanged. Script went from 37 to 94 lines (was 159).

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Commitizen bump preview

No commits in this PR are eligible for a version bump.

`scripts/gen_cli_interactive_gifs.py` now renders tapes through a
ThreadPoolExecutor (default capped at `min(len(tapes), 4)`, override
via `-j`), so a full re-render takes one slow tape's runtime instead
of the sum of all five.

Make `shared/base.tape` and `shared/cleanup.tape` use a per-tape
`mktemp -d` workdir instead of the hardcoded `/tmp/commitizen-example`,
so concurrent vhs runs do not race on the same directory.

Generated-by: GitHub Copilot CLI (claude-opus-4.7-1m-internal)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bearomorphism
bearomorphism force-pushed the script-parallel-filter branch from 68fadd8 to daffcb6 Compare May 30, 2026 07:30
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Commitizen bump preview

No commits in this PR are eligible for a version bump.

@bearomorphism bearomorphism changed the title chore(scripts): parallel + filterable cli_interactive gif rendering May 30, 2026
@bearomorphism

Copy link
Copy Markdown
Collaborator Author

Trimmed further at daffcb6: dropped the tape-name filtering (CLI positional + by_stem resolution + dedup loop) per discussion. The script now just runs every *.tape in parallel; -j is the only remaining flag. PR diff is now +71/-29 (was +151/-29), script is 68 lines (was 159, original 37). Re-titled accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 participant