Repository navigation
feat(file): add newest_by_stem to read only the newest of same-name files - #144
Ankur Gupta (ankur-pattern) wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Active issues violate retained file ordering and make disabled newest-by-stem reads abort on unnecessary stat failures, potentially dropping readable files without failing the pipeline.
2 open issues
What changed in this PR
Adds opt-in newest_by_stem selection to file sources so pipelines can choose the latest report across extensions before downstream conversion.
Changes:
- Selects one file per directory and stem using local or S3 modification times.
- Adds deterministic tie-breaking and logs skipped files.
- Documents the option and adds grouping and local-read tests.
| File | Description |
|---|---|
internal/pkg/pipeline/task/file/s3.go |
Includes S3 modification times in listed sources. |
internal/pkg/pipeline/task/file/README.md |
Documents selection rules and configuration. |
internal/pkg/pipeline/task/file/local.go |
Collects local modification times. |
internal/pkg/pipeline/task/file/file.go |
Adds configuration, selection logic, and skip logging. |
internal/pkg/pipeline/task/file/file_test.go |
Tests grouping rules and enabled/disabled local reads. |
Review effort: Balanced
|
/argus review |
4f32c50 to
aed67d2
Compare
|
/argus review |
There was a problem hiding this comment.
Argus review of aed67d2: checked the newest_by_stem grouping logic, the reader.parse signature change (both implementations updated; no other callers), S3 LastModified / local mtime collection, and the README entry. Inline comments cover the dotfile grouping edge case, silent skips, and the unconditional local os.Stat.
No tests for newest_by_stem
Severity: Medium
The PR adds a selection rule that drops input files, but the head commit adds no tests (the file package has no _test.go), and the S3 path is still unchecked in the test plan. newestByStem is a pure function over []source, so it can be tested without S3 or the filesystem.
Fix: Add a table-driven file_test.go covering: same stem with different extensions (newer wins, either listing order); same stem in different directories (both kept); different stems (both kept); equal modification times (first listed kept, which matters for S3's one-second LastModified precision); multi-dot names like a.tar.gz vs a.zip; and leading-dot names. Add one readFile test over a temp dir with newest_by_stem on and off.
…art, log skipped files

Summary
newest_by_stemto thefiletask's read mode. When it is set, of the matched files in the same directory whose names differ only by extension (for examplereport.xlsxandreport.tsv), only the most recently modified one is read.LastModified, or the file's modification time for local paths.Test plan
go build ./...,go vet -copylocks=false ./...,go test -race ./...report.xlsx, a newerreport.tsvandother.xlsx: withnewest_by_stem: trueonlyreport.tsvandother.xlsxare read, and without it all three aretest/pipelines/file_read_failure.yamlstill fails as onmainreport.xlsxandreport.tsvreads only the newer object