Use pattern matching to filter invalid tile filenames from discovery#107
Use pattern matching to filter invalid tile filenames from discovery#107
Conversation
Co-authored-by: avsm <53164+avsm@users.noreply.github.com>
Co-authored-by: avsm <53164+avsm@users.noreply.github.com>
avsm
left a comment
There was a problem hiding this comment.
Take a different approach: when discovering tiles, ignore all files that fail to pattern match the regexp for tiles and skip them. If the relevant npy and scales files exist, then that's sufficient for the function to return that metadata. Be robust to extra files being present, which might include temp files but also be other files.
|
@copilot do another round of changes in response to my review |
…icit temp file check Co-authored-by: avsm <53164+avsm@users.noreply.github.com>
…eption handling Co-authored-by: avsm <53164+avsm@users.noreply.github.com>
Updated the implementation to use pattern-based filtering as suggested. Files that don't match the expected tile naming patterns (validated by regex in the parsing functions) are now silently skipped via Changes in commit 588afe9 |
|
@copilot the tests are failing due to this |
…gatives Co-authored-by: avsm <53164+avsm@users.noreply.github.com>
Fixed the test failures. The issue was that the regex pattern pre-filtering in Changes in commit 9abf770 |
|
@copilot remove the test case and modify one of the .t cram tests to create manually created tmp files and run the discovery tiles from a cli function to check the warnings dont appear |
- Removed tests/test_tile_discovery.py unit test file
- Added new cram test in tests/cli.t that creates temporary files manually
- Test verifies info command silently ignores temp files without warnings
- Test creates files matching typical temporary file patterns (.{name}_tmp_*)
- Test validates tile count remains correct and no warnings appear
Co-authored-by: avsm <53164+avsm@users.noreply.github.com>
Replaced unit tests with cram test as requested. The new test in cli.t:
Changes in commit 440e6d6 |
|
@copilot merge your branch against the current main branch to get all the latest changes |
Fix tmp tiles in tile discovery
The issue: When geotessera is interrupted during tile download, temporary files with pattern
.{filename}_tmp_*are left in the tiles directory. These temporary files cause warnings during tile discovery.Changes
discover_npy_tiles(),discover_geotiff_tiles(),discover_zarr_tiles()- Addedexcept ValueErrorto silently skip files that don't match expected filename patternsdiscover_tiles()- Removed over-strict pattern pre-filtering that was causing false negativesImplementation
The solution relies on existing filename parsing functions that validate filenames against expected patterns using regex. When a file doesn't match the pattern, the parsing function raises
ValueError, which is caught and the file is silently skipped:This approach is robust to any extra files (temporary files, hidden files, incorrectly named files, etc.) that may be present in tile directories.
Testing
Cram test validates temporary files are silently ignored
Test creates temporary files matching real-world patterns
Verifies info command works correctly without warnings
Fixes tmp tiles should be ignored in tile discovery #106
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.