Skip to content

Test performance improvements#33

Open
samn wants to merge 4 commits intomasterfrom
cursor/test-performance-improvements-b54c
Open

Test performance improvements#33
samn wants to merge 4 commits intomasterfrom
cursor/test-performance-improvements-b54c

Conversation

@samn
Copy link
Member

@samn samn commented Feb 4, 2026

Cache static hydrology data and enable CI caching to significantly improve test performance.

Previously, static hydrology data (~85MB) was re-downloaded for every test run, leading to slow execution. This PR introduces a persistent local cache (.test_cache/) for downloaded hydrology data, integrates it with GitHub Actions for CI caching, and updates test configurations to utilize this shared cache. It also adds pytest-xdist for parallel test execution and provides session-scoped fixtures for sharing expensive delineation results. The changes resulted in a 36% speedup for cached test runs (from 97.92s to 62.28s).


Open in Cursor Open in Web

cursoragent and others added 2 commits February 4, 2026 14:29
- Add persistent cache directory for downloaded hydrology data
  - Data persists across test runs (in .test_cache/)
  - Significantly reduces test execution time on subsequent runs

- Update test fixtures to use shared cache directory
  - default_config and consolidate_config now include CACHE_DIR
  - All tests share the same cache for downloaded files

- Add GitHub Actions cache for test data
  - Uses actions/cache to persist .test_cache between CI runs
  - First CI run downloads data, subsequent runs use cache

- Add pytest-xdist for parallel test capability
  - Available for local parallel test execution if desired

Performance improvement: ~36% faster on cached runs (97s -> 62s)

Co-authored-by: Sam Neubardt <samneubardt@gmail.com>
- Document cache location and size (~85MB)
- Explain how to clear the cache
- Note CI cache key versioning
- Describe available session-scoped fixtures for future optimization

Co-authored-by: Sam Neubardt <samneubardt@gmail.com>
@cursor
Copy link

cursor bot commented Feb 4, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

cursoragent and others added 2 commits February 4, 2026 14:55
- Fix download_if_missing to handle partial/corrupted downloads:
  - Check file size > 0, not just existence
  - Use atomic writes (temp file + rename) to prevent caching incomplete files
  - Clean up corrupted 0-byte files automatically
  - Increase timeout from 10s to 30s for large files

- Fix CI cache workflow:
  - Split into separate restore/save steps
  - Only save cache if not already cached (prevents overwriting good cache)
  - Bump cache key to v2 to invalidate any corrupted cache

This fixes the issue where interrupted downloads created 0-byte files
that would never be re-downloaded.

Co-authored-by: Sam Neubardt <samneubardt@gmail.com>
@samn samn marked this pull request as ready for review February 5, 2026 15:38
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.

2 participants