Skip to content

temporal: Avoid PLY debug-mode overhead in raster algebra gunittest - #693

Closed
echoix wants to merge 1 commit into
mainfrom
claude/macos-raster-algebra-timeout-investigation
Closed

echoix wants to merge 1 commit into
mainfrom
claude/macos-raster-algebra-timeout-investigation

Conversation

@echoix

@echoix echoix commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

Description

unittests_temporal_raster_algebra.py constructs TemporalRasterAlgebraParser(..., debug=True) in all 43 of its test methods. That flag makes the vendored PLY yacc.yacc() rebuild and dump the full LALR debug trace to parser.out on every call — measured locally at 2.86 MB per dump, identical every time since the grammar is static, and the file handle is never closed (ResourceWarning: unclosed file ...'parser.out'). None of this is used by the tests. Production code (t.rast.algebra.py) already uses debug=False, as does the base class's own default; only this test file overrides it.

This PR switches all 45 instantiations in that file to debug=False, matching production usage and removing ~129 MB of redundant writes and 45 leaked file descriptors per test run.

Motivation and context

Investigating an intermittent macOS-only CI timeout on this exact test file (Timeout >300.0s). I can't prove this fixes that specific timeout — comparing recent macOS CI runs shows the same 300s ceiling hit by an unrelated test on a different occasion, which points more to runner-level I/O contention than a deterministic bug, and a local before/after timing comparison showed no measurable difference on a fast disk. This change is a genuine, independently-justified cleanup (dead debug output, a real leaked file handle) that reduces this file's exposure to slow/contended disk, not a targeted fix for the flake.

How has this been tested?

Built GRASS from source locally and ran unittests_temporal_raster_algebra.py directly, both before (debug=True) and after (debug=False): 43/43 tests pass both ways, confirming no behavioral change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • PR title provides summary of the changes and starts with one of the pre-defined prefixes
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes. (test-only change; existing 43 tests still pass)

Investigated and fixed with AI assistance (Claude Code); the analysis, the decision of what (not) to fix, and the verification above are mine.

🤖 Generated with Claude Code

@echoix
echoix force-pushed the claude/macos-raster-algebra-timeout-investigation branch from 6508cff to 058deb9 Compare September 5, 2026 20:52
unittests_temporal_raster_algebra.py instantiates
TemporalRasterAlgebraParser with debug=True in all 43 of its test
methods (45 instantiations), far more than any sibling test file in
this family (the next highest is 26). With debug=True, the vendored
PLY yacc.yacc() (python/grass/temporal/ply/yacc.py) rebuilds and
verbosely logs the full LALR table on every call, and opens a
parser.out debug file that is never closed (confirmed by a
"ResourceWarning: unclosed file ... 'parser.out'" in a macOS CI log),
in addition to enabling extra "if self.debug: print(...)" statements
throughout temporal_raster_base_algebra.py. None of this output is
used by the tests or by CI.

This matches a macOS-only CI failure where this file alone timed out
at the gunittest per-file limit (FAILED ... Timeout >300.0s) after
completing only a fraction of its tests, while the same file runs all
43 tests in about a minute on Linux CI. The production CLI tool
(t.rast.algebra.py) already calls this parser with debug=False, and
TemporalRasterBaseAlgebraParser's own default is debug=False; only
this test file's parser subclass overrode it to True. Passing
debug=False here removes avoidable per-test disk I/O and redundant
LALR logging that a contended or slow-disk CI runner would feel most,
without changing what is tested (no test inspects the debug output).

Investigated by pulling recent macOS Actions runs on this fork,
reading the gunittest and PLY yacc internals, and comparing timing
across CI runs; see PR description for the full analysis.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@echoix
echoix force-pushed the claude/macos-raster-algebra-timeout-investigation branch from 058deb9 to dc8f658 Compare September 5, 2026 21:04
@echoix echoix closed this Sep 12, 2026
@echoix
echoix deleted the claude/macos-raster-algebra-timeout-investigation branch September 12, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant