Skip to content

For notifications - #1

Open
Ossifragus wants to merge 108 commits into
notificationsfrom
master
Open

Ossifragus wants to merge 108 commits into
notificationsfrom
master

Conversation

@Ossifragus

Copy link
Copy Markdown
Owner

No description provided.

Ossifragus and others added 30 commits July 22, 2022 14:16
Ossifragus and others added 30 commits January 17, 2025 23:18
… path

Three bugs in the v2.4 writeChunk/showChunk implementation:

1. Stream exhaustion: writeChunk called \newread and \newwrite inside the
   command body, permanently consuming a TeX stream register on every
   invocation. With only 16 read and 16 write streams available, any
   document with more than 16 showChunk/runRChunk calls would crash with
   "No room for a new read stream." Fixed by declaring \runcodeReadStream
   and \runcodeWriteStream once at package load time and reusing them.

2. Unknown shell command: showChunk called \write18{ad ...} before each
   writeChunk. "ad" is not a standard command on macOS/Linux and has no
   effect. Removed; writeChunk now handles directory creation itself.

3. Subdirectory path: writeChunk wrote chunk files to generated/<srcpath>
   without creating intermediate directories, so a source file like
   code/stats.R would produce generated/code/stats.R-label.txt but the
   generated/code/ directory did not exist. Fixed by running mkdir -p on
   the directory component (via \filename@parse) inside writeChunk.

Add examples/ChunkTest with 7 targeted test cases covering all three
fixes: subdirectory source files, flat source files, 18 consecutive
showChunk calls (exceeding the old 16-stream limit), runRChunk, and
graceful error display for missing labels and missing files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace \filename@parse + mkdir -p with python3 os.makedirs for
cross-platform subdirectory creation in writeChunk. mkdir -p is
unavailable on Windows and is sensitive to \filename@area expansion
differences across TeX distributions.

Add AUCTeX magic comment and explanation to ChunkTest.tex so Emacs
users get --shell-escape automatically; without it \write18 is silently
skipped and the generated/ directory tree is never created.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update \ProvidesPackage date and version, add v2.4.1 changelog entry
to README.org, update CTAN/README, and rebuild runcode_troubleshoot.pdf
against the updated runcode.sty.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Issues fixed:
- Default mode now uses MD5 checksums of source files to skip code
  execution when content is unchanged (Issue #10). Previously, every
  compile re-executed all code even when nothing changed.
- \inln in [cache] mode no longer produces empty output when no cache
  file exists; output is always run when the .tex output file is missing
  regardless of \ifruncode state (Issue #16).
- Added \ifforcerun flag so [run] option forces execution while default
  mode uses the smart checksum path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests smart checksum cache (Issue #10) and \inln missing-output
fallback (Issue #16) across all three languages:
- \runRChunk / \runPythonChunk / \runJuliaChunk: per-chunk MD5 cache
- \runRIncOut / \runPythonIncOut / \runJuliaIncOut: whole-file MD5 cache
- \inlnR / \inlnPython / \inlnJulia: backtick inline mode
- Named fallback test to exercise Issue #16 fix in [cache] mode

Verified: second compile leaves all chunk/file .tex outputs unchanged
(only backtick-mode \inln reruns, which has no persistent source to checksum).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds code/hello.m with labeled chunks (ml-sum, ml-mean, ml-hello)
and a Matlab section in CacheTest.tex covering \runMatLabChunk,
\runMatLabIncOut, and \inlnMatLab. The section is guarded by
\newif\ifuseMatlab (default false) so the file compiles on systems
without Matlab. Enable with \useMatlabtrue and add [matlab] to the
\usepackage options.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Addresses the race conditions in nohup server mode:
- wait_for_rserver.py: polls the talk2stat server until it accepts
  connections; supports R, python, julia, matlab via CLI arg.
- runcode-Makefile.sample: sample Makefile encoding the three fixes
  (QUIT old server, wait for ready, sync barrier before second pass)
  with PIPETIMEOUT guidance and support for multiple languages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Generalizes make_overleaf.py into a standalone tool for any runcode project.
Transforms all .tex files by replacing \includeOutput, \inlnR/Python/Julia/
MatLab, \runRIncOut/Chunk, and \runCodeIncOut with cached content from
generated/, and replaces \usepackage{runcode} with a tcolorbox+listings shim.
Run-only commands (\runR etc.) are dropped. Auto-numbered outputs are left
as-is with a note to review manually.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- \runRChunk etc.: derive label as src-chunk when no explicit label given
- patch_usepackage: skip comment lines; broaden regex to match relative
  paths like {../../runcode} in addition to plain {runcode}
- Fix re.sub backslash-in-replacement error (use lambda)

Tested on examples/CacheTest: PDF compiles successfully.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
README.org: add v2.5 revision entry covering checksum cache invalidation,
wait_for_rserver.py, runcode-Makefile.sample, and consolidate.py.

CTAN/README: add the three new files to the Files section; update
copyright year to 2026.

.ctan.sh: include wait_for_rserver.py, runcode-Makefile.sample, and
consolidate.py in the CTAN tarball.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New files:
- wait_for_server.py (renamed from wait_for_rserver.py; works for all languages)
- runcode.tex / runcode.pdf: documentation rewritten directly in LaTeX,
  replacing the broken Emacs org→tex workflow; covers all v2.5+ features
- consolidate.py: generalised make_overleaf.py; inlines cached outputs
  for standalone submission (Overleaf, journals, etc.)
- runcode-Makefile.sample: nohup Makefile with server lifecycle,
  startup sync, and draft-pass barrier

Documentation improvements:
- Added reducedspace option, code-display style section (\setminted/
  \fvset/\lstset), checksum cache behaviour under \runExtCode,
  \writeChunk entry, \inln type variants, \runLANGChunk label default,
  AUCTeX magic-comment tip, and nohup→Section 3 cross-reference
- runcode_troubleshoot.tex: new nohup race-condition entry; updated
  cache-clearing section to reflect v2.5 auto-invalidation

Package:
- runcode.sty: version bumped to v2.6 (2026/06/13)
- .gitignore: stop ignoring runcode.tex and runcode.pdf (now maintained
  directly rather than generated from runcode.org)
- .ctan.sh: substitutes XXX-Date Version-XXX placeholder in the three
  new auxiliary files at package-time

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- .ctan.sh: generate README from CTAN/README (with version substituted)
  instead of copying a non-existent root README
- runcode.tex: correct header comment from v2.5 to v2.6

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
writeChunk re-scanned its whole source file, line by line, via a slow
TeX-native loop on every call, with no caching, unlike every other
command in the package (runExtCode, includeOutput, inln all check
before doing expensive work). On documents with many showChunk calls
against large source files, across the multiple xelatex passes a
typical build requires, this dominated compile time: in a real-world
document, a single pass went from 3m33s to 11s once showChunk calls
were disabled, isolating writeChunk as the bottleneck.

writeChunk now applies the same MD5 checksum-based staleness check
already used by runExtCode elsewhere in this file: the scan is skipped
and generated/<src>-<id>.txt reused whenever <src> is unchanged since
it was last extracted, so editing the source automatically invalidates
the right cache entries with no manual cleanup step required.

Verified against examples/ChunkTest (the existing writeChunk/showChunk
regression test): correct extraction across subdirectory and flat-file
sources, correct staleness invalidation on source edits, correct full
caching on stable recompiles, and both error paths (missing label,
missing source file) still behave correctly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Cache writeChunk extraction with MD5 staleness check (v2.6.1)
generated/ directories hold regeneratable cache/extraction output
(runExtCode, writeChunk, etc.) and are gitignored everywhere except
two spots that predate the *generated rule: examples/Collaborate/
generated/ (carved back in via a .gitignore exception) and a
top-level generated/ with a few files added before the rule existed.
Untrack both so *generated applies uniformly; the files remain on
disk, untouched, just no longer tracked.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
runcode.tex has been hand-maintained directly since v2.6 (891eb55,
"replacing the broken Emacs org->tex workflow"), but
.github/workflows/ctan.yml was never updated to match: it still ran
.org2tex.sh, which regenerates runcode.tex from README.org before
compiling. Verified this concretely by downloading the published v2.6
GitHub release's tarball: its runcode.tex has \date{\today} and zero
\DescribeMacro entries, confirming it shipped the old org-generated
manual instead of the hand-polished one committed to the repo.

- .github/workflows/ctan.yml: drop the Emacs setup and
  "generate runcode.tex" steps; compile the committed runcode.tex
  directly, as intended since v2.6.
- Delete .org2tex.sh, .org2tex.el, and CTAN/header.tex: dead once the
  workflow no longer calls them, and reviving the org pipeline isn't
  worthwhile — its LaTeX export is structurally worse (auto-generated
  section labels, no custom macros, minted instead of listings for
  code snippets) than the hand-written runcode.tex, which is why it
  was abandoned in the first place. Verified by actually running the
  export locally (installed Emacs + org) rather than assuming.
- README.org: add a note that it no longer generates runcode.tex but
  remains the GitHub repo landing page (there is no README.md). Also
  add the v2.6.1 changelog entry and writeChunk caching note to keep
  its own content current, since it's still user-facing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…tirement

Companion to 3f63f8a (which deleted the dead org->LaTeX scripts but
missed staging these two files due to a git add pathspec error):
drop the Emacs setup / .org2tex.sh steps from the release workflow so
it compiles the already-hand-maintained runcode.tex directly, and add
a note plus the v2.6.1 changelog/writeChunk entries to README.org.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
v2.6.1 fixed writeChunk's missing cache with an MD5 checksum check, but
that check ran unconditionally -- including under the "cache" package
option, where it defeats the point: on Overleaf (put into cache mode by
workflows like the nostarch project's make_overleaf.py) this meant one
python3 subprocess spawn per \showChunk call, on every compile, even
with a fully warm cache.

writeChunk now checks \ifruncode first, matching \runExtCode and \inln
elsewhere in this file: in cache mode it trusts an existing cached file
outright with zero subprocess calls; the checksum check only runs in
normal (non-cache) mode, where it's actually needed to detect edits.

Added examples/WriteChunkCacheTest/ as a permanent, automated regression
test (not part of the CTAN release -- .ctan.sh never touches examples/)
covering the full factorial design behind this: \ifruncode true/false x
generated-file missing/fresh/stale, 6 meaningful cells. Verified the test
actually catches the regression it's meant to prevent by running it
against the pre-fix code and confirming the cache-mode cases fail there.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
writeChunk: skip the checksum subprocess entirely in cache mode (v2.6.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants