Repository navigation
OCSDV-452 (PR-A): data sync include/exclude filter models + shared filter helper - #54
Conversation
…lter helper Adds the core-side half of data sync include/exclude filtering (PR-A). - New `DataSyncFilterConfig(include, exclude)` with `include_patterns` / `exclude_patterns` cached-property accessors, following the existing `ListDataPathsRequest` convention in aibs-informatics-aws-lambda. - `DataSyncTask` gains `filter_config` (what to move) and `filter_root` (internal plumbing set by the prepare handler so patterns stay anchored across the prepare -> batch split). - `DataSyncConfig` gains `delete: bool = True`, documenting that filters combined with `delete=True` remove non-matching files already present at the destination. Deliberately unguarded; `delete` is the gate. - `DataSyncRequest.config` / `.task` enumerate fields by hand, so the new fields are added there explicitly, with tests that fail if a future field is dropped. - New `utils/filters.py` holds the single filter contract: regex patterns matched with `fullmatch` against the path relative to a supplied root, exclude beats include, empty include includes everything. - `find_paths` now routes through that helper. Behavior change: it previously matched the full absolute path. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #54 +/- ##
==========================================
- Coverage 97.10% 97.09% -0.01%
==========================================
Files 57 58 +1
Lines 3347 3412 +65
Branches 382 391 +9
==========================================
+ Hits 3250 3313 +63
- Misses 53 54 +1
- Partials 44 45 +1
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a shared include/exclude filtering contract and wires it into core data-sync models and local path discovery so filtering semantics are consistent across local/S3/EFS listings.
Changes:
- Introduces
utils/filters.pywith shared helpers for compiling patterns, relativizing paths, and applying include/exclude rules usingre.fullmatch. - Adds
DataSyncFilterConfig,DataSyncTask.filter_config/filter_root, andDataSyncConfig.deletetomodels/data_sync.py, plus stronger tests to ensureDataSyncRequest.config/.taskcarry all fields. - Routes
find_pathsthrough the shared helper and adds tests that pin the new “match relative to root” behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/aibs_informatics_core/utils/filters.py |
New shared filtering helpers establishing a single include/exclude contract. |
src/aibs_informatics_core/utils/file_operations.py |
Updates find_paths to apply filters via the shared helper (relative-to-root + fullmatch). |
src/aibs_informatics_core/models/data_sync.py |
Adds filter models/fields and exposes delete on config; updates DataSyncRequest.config / .task. |
test/aibs_informatics_core/utils/test_filters.py |
New unit tests covering shared filtering semantics and edge cases. |
test/aibs_informatics_core/utils/test_file_operations.py |
Adds tests pinning find_paths relative-filter behavior and file-root handling. |
test/aibs_informatics_core/models/test_data_sync.py |
Adds/updates serialization and field-carrying tests for new data sync filter/delete fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| include: str | list[str] | None = None | ||
| exclude: str | list[str] | None = None | ||
|
|
There was a problem hiding this comment.
ok I will remove the cached_property
| sub-requests rooted at ``s3://b/run1/sampleA/``. Each sub-request | ||
| re-lists from its own root, so patterns written against ``run1/`` | ||
| would silently stop matching. Sub-requests therefore carry the | ||
| original root here. Defaults to the source path when unset. | ||
| """ |
filter_paths selected paths but always returned list[str], forcing callers holding Path objects to re-wrap every element. It now selects without rewriting and is typed with a bound TypeVar, so the element type survives: list[Path] -> list[Path], list[str] -> list[str]. The TypeVar is bound rather than constrained deliberately. S3Path subclasses str (via ValidatedStr), so a constrained TypeVar -- or a pair of str/Path overloads -- would widen list[S3Path] back to list[str], which is exactly the type the aws-utils sync code wants to keep hold of. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (3)
test/aibs_informatics_core/utils/test_filters.py:36
re.Patternobjects generally don't compare equal unless they're the same object, so this assertion is likely to fail by comparing against a newly-compiled pattern. It’s safer to assert identity for the pass-through pattern and compare.patternfor the compiled string input.
def test__compile_patterns__passes_through_compiled_patterns():
pattern = re.compile(r".*\.txt")
assert compile_patterns(pattern) == [pattern]
assert compile_patterns([pattern, r"b.*"]) == [pattern, re.compile(r"b.*")]
src/aibs_informatics_core/models/data_sync.py:112
- The docstring says
filter_root"Defaults to the source path when unset", but the field default isNoneand there’s no validator or property implementing that default. This can mislead readers; either implement the defaulting behavior or adjust the doc to reflect that callers must treatNoneas "use source_path".
original root here. Defaults to the source path when unset.
src/aibs_informatics_core/utils/file_operations.py:372
- The
includes/excludesargs are typed asSequence[Pattern | str], but the docstring still documents them asSequence[str]. Updating the doc avoids confusion and makes it clear compiled regexes are supported.
include_files (bool, optional): whether to include files. Defaults to True.
includes (Sequence[str], optional): list of regex patterns to include. Defaults to all.
excludes (Sequence[str], optional): list of regex patterns to exclude. Defaults to None.
LOC breakdownAlthough GitHub reports 654 additions and 23 deletions, most of the change is tests, documentation, comments, and typing rather than new source-code logic.
Changes by file
Estimated source-code logic changeManual classification puts the actual new executable production logic at approximately 55–60 lines:
The deletions primarily remove the old inline filtering implementation, replacing it with the shared helper. Bottom line: this is a well-tested, heavily documented change with roughly 55–60 lines of new runtime behavior, despite the headline +654 / -23 LOC. |
Generated AWS resource names sometimes have to fit a downstream length limit,
and plain truncation risks collisions. condense_str keeps as much readable
prefix as fits and appends a hash of the FULL original value, so two values
sharing a long prefix still condense differently.
Two properties callers depend on:
* a value that already fits is returned unchanged, so adopting this helper
renames nothing that was previously in budget
* the result is deterministic, so names do not churn between runs
Raises rather than silently truncating when the budget cannot fit the hash
suffix plus a prefix character; a bare-hash fallback would quietly invite the
collisions this exists to prevent.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (3)
test/aibs_informatics_core/utils/test_filters.py:36
- The
compile_patternspassthrough test compares lists of compiledre.Patternobjects directly. Pattern objects don't have stable value-based equality, so this assertion can fail even when the patterns are correct. Compare identity for the passthrough element and compare.patternstrings for compiled results instead.
def test__compile_patterns__passes_through_compiled_patterns():
pattern = re.compile(r".*\.txt")
assert compile_patterns(pattern) == [pattern]
assert compile_patterns([pattern, r"b.*"]) == [pattern, re.compile(r"b.*")]
src/aibs_informatics_core/models/data_sync.py:113
DataSyncTask.filter_rootis documented as "Defaults to the source path when unset", but the field default isNoneand there’s no validator or property here that applies that default. Either implement that defaulting behavior or adjust the docstring so it doesn’t promise a behavior the model doesn’t provide.
re-lists from its own root, so patterns written against ``run1/``
would silently stop matching. Sub-requests therefore carry the
original root here. Defaults to the source path when unset.
"""
src/aibs_informatics_core/utils/file_operations.py:375
- The
find_pathsdocstring says it returns "absolute paths" underroot, butfind_all_paths()returns whateveros.walk()yields. Ifrootis relative, the returned paths will also be relative. Update the docstring to avoid claiming the paths are absolute.
Returns:
list of paths matching criteria (as absolute paths under ``root``)
Review feedback on PR #54. DataSyncFilterConfig.include_patterns/exclude_patterns were cached_property on a mutable pydantic model, so reassigning include/exclude left the compiled patterns stale -- the config would serialize one set of patterns while filtering by another. Reproduced both by direct assignment and via model_copy(update=...). Converted to plain properties rather than freezing the model. Freezing blocks assignment but does NOT close the model_copy path, because pydantic copies the instance __dict__ with the populated cache along with the fields; it also synthesizes a __hash__ that raises on the list-valued fields. Recompiling is cheap since re.compile keeps its own module-level cache. Two tests pin this, and both fail if cached_property is restored. Docstrings: * DataSyncTask.filter_root claimed it "Defaults to the source path when unset", but the model applies no fallback -- the consumer does. Reworded to say None means "not set", and to record why resolving it here would be wrong: it would materialize source_path into the serialized task, which to_dict() currently omits while the field is None. * find_paths said it returns "absolute paths under root". It returns paths prefixed with root as given, so a relative root yields relative paths (verified). That line was added by this PR. While there, corrected the includes/excludes parameter types, documented as Sequence[str] but actually Sequence[Pattern | str] -- pre-existing drift in the same docstring. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/aibs_informatics_core/models/data_sync.py:98
- PR description states
include_patterns/exclude_patternsare@cached_property, but the implementation here is plain@property(which is consistent with the in-code comment about avoiding staleness on mutation). Please update the PR description (or any associated docs) so it matches the actual behavior, to avoid downstream consumers assuming caching semantics.
# Deliberately plain properties, not cached_property. This model is mutable, and a
# cached compile would go stale the moment `include`/`exclude` changed -- leaving the
# config serializing one set of patterns while filtering by another. The staleness
# also survives `model_copy(update=...)`, which copies the populated instance __dict__
# along with the fields, so freezing the model would not close that path either.
# Recompiling is cheap: `re.compile` keeps its own module-level cache.
@property
def include_patterns(self) -> list[Pattern] | None:
return compile_patterns(self.include)
@property
def exclude_patterns(self) -> list[Pattern] | None:
return compile_patterns(self.exclude)
src/aibs_informatics_core/utils/tools/strtools.py:29
- This PR introduces the new public helper
condense_str(exported via__all__) and adds tests for it, but the PR description’s change list does not mention it. If this is intentional cross-PR plumbing (e.g., for downstream AWS name length limits), please call it out explicitly in the PR description; otherwise consider deferring it to the PR where it’s used to keep scope focused.
__all__ = [
"camelcase",
"condense_str",
"is_prefixed",
"is_suffixed",
"lowercase",
"pascalcase",
"removeprefix",
"removesuffix",
"snakecase",
"spinalcase",
"uppercase",
]
import stringcase
from aibs_informatics_core.utils.hashing import sha256_hexdigest
#: Hex characters of hash appended by :func:`condense_str` when shortening. 8 hex
#: characters is 32 bits, ample for disambiguating names within a single namespace.
DEFAULT_CONDENSE_HASH_LENGTH = 8
def condense_str(
value: str,
max_length: int,
delimiter: str = "-",
hash_length: int = DEFAULT_CONDENSE_HASH_LENGTH,
) -> str:
Review feedback (schristinelin on #55): the "do these filters filter anything" check is written in more than one place, and differently -- `bool(x) or bool(y)` in one, `not x and not y` in another. Logically equivalent today, which is how drift starts. from_patterns() is now the one definition, returning None when nothing is actually filtered so that empty reads as absent. That distinction is load-bearing: sanitize_serialized_params branches on filter presence and feeds an execution hash, so an empty-but-present config must not read as filtered. Also adds a parity test that fails if DataSyncFilterConfig gains a field. ResolvableBase and ResolvableJobParam mirror include/exclude as their own flat fields rather than nesting this model -- deliberately, to keep the demand execution models independent of the data sync schema -- so a new field here would be silently absent there and a value-comparing test would stay green. The test's docstring carries the migration note, including that a bare field swap to a nested config would silently drop filters from flat payloads, since PydanticBaseModel sets extra="ignore". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/aibs_informatics_core/utils/filters.py:94
get_relative_pathonly treatspathas equal torootwhen the strings match exactly. Ifpathincludes a trailing slash (common for S3 “directory marker” keys or caller-provided roots) androotdoes not (or vice versa), the function will return an empty relative path via the prefix-strip branch instead of the intended basename. That makesfullmatch-based filters behave unexpectedly for that edge case.
str_root = str(root).rstrip("/")
if not str_root:
return str_path.lstrip("/")
if str_path == str_root:
return basename(str_path)
Jira: OCSDV-452 — PR-A of 5, release R1.
This is the
aibs-informatics-corehalf of data sync include/exclude filtering. It adds the models and the one shared filter helper that the aws-utils (PR-C) and aws-lambda (PR-D) changes will route through. No version bump — core releases once, after PR-B (OCSDV-453) lands.What's here
1.
DataSyncFilterConfig(models/data_sync.py)include/excludeasstr | list[str] | None, withinclude_patterns/exclude_patterns@cached_propertyaccessors compiling tore.Pattern. This copies the convention already used byListDataPathsRequestinaibs_informatics_aws_lambda/handlers/data_sync/model.py, so the two stay consistent — the difference is that the compile step is now the sharedcompile_patternshelper rather than a private static method.2.
DataSyncTask.filter_config/.filter_rootFilters describe what to move, so they hang off the task rather than the config.
filter_rootis internal plumbing — set by the prepare handler, never by users, and documented as such on the field. It exists because the distributed workflow splits a sync ofs3://b/run1/into sub-requests rooted ats3://b/run1/sampleA/; each sub-request re-lists from its own root, so a pattern written againstrun1/would silently stop matching without an explicit anchor.Note for PR-D:
filter_rootis typedstr | Noneper the refinement decision, and Pydantic will not coerce aPathinto it — the prepare handler needs to passstr(...).3.
DataSyncConfig.delete: bool = TrueCurrently hardcoded
Trueat three sites indata_sync/operations.py; this exposes it. The field carries a prominent warning: filters narrow what the sync considers "the source", so withdelete=Trueany file already at the destination that the filters exclude is treated as unexpected and deleted. Callers who filter are expected to passdelete=False.There is deliberately no validator blocking
filter_config+delete=True— mirroring a filtered subset is a legitimate use, anddeleteis the gate. Per the ticket's Known gaps section.4.
DataSyncRequest.config/.taskBoth properties enumerate fields by hand, so new fields are silently dropped unless added. The new fields are added, and two tests (
test__DataSyncRequest__config_carries_every_config_field,..._task_carries_every_task_field) now iteratemodel_fieldsso a future dropped field fails CI instead of going unnoticed.5.
utils/filters.py— the one shared helperNew module, deliberately separate from
file_operations.py: S3 code paths in aws-utils will import it, andfile_operationspulls infcntl/tarfile/archive machinery they don't need.The contract, in one place:
re.fullmatch— the pattern must describe the whole pathincludeincludes everythingPublic surface:
compile_patterns,get_relative_path,path_matches_filters(per-path predicate, for in-loop S3 listing),filter_paths(batch, compiles once).filter_pathsis type preserving. It selects from the paths it is given without rewriting them, and is typed with a boundTypeVar:So
list[Path]->list[Path],list[str]->list[str],list[S3Path]->list[S3Path], and callers holdingPathobjects no longer have to re-wrap every element. TheTypeVaris bound rather than constrained on purpose:S3Pathsubclassesstr(viaValidatedStr), so a constrainedTypeVar— or a pair ofstr/Path@overloads — would widenlist[S3Path]back tolist[str], which is exactly the type the aws-utils sync code wants to keep hold of. Verified against mypy rather than assumed.get_relative_pathis string-prefix based rather thanpathlibbased on purpose —Path("s3://bucket/key")collapses the//and mangles the scheme. Two edge cases worth review: when the path is the root (single-file source) it relativizes to the base name so patterns still have something to match, and when the path is not under the root at all it is returned unchanged.6.
find_pathsrouted through the helperBehavior change:
find_pathspreviously matched patterns against the full absolute path. It now matches against the path relative toroot. Concretely,excludes=[r"sample/.*"]used to do nothing under a local root while working under S3; now it behaves the same in both places. This is design decision #1 in the ticket, unifying three inconsistent implementations.On the ~13 existing
find_pathstestsThe ticket flagged these as needing deliberate updating. In the end, none of their assertions changed — all 53 tests in
test_file_operations.pypass untouched.The reason: every existing filter test uses patterns already prefixed with
.*(.*\.txt,.*\.log,.*d2.*,.*b\.txt). Underfullmatch, a leading.*absorbs whichever prefix is present, so those patterns match identically against/tmp/xyz/a.txtanda.txt. The tests were written prefix-agnostically and are blind to the change.That also means the existing suite did not pin the new behavior, so rather than editing assertions I added four tests that do:
test__find_paths__patterns_are_matched_relative_to_rootincludes=["sub/.*"]now matches; previously matched nothingtest__find_paths__absolute_patterns_no_longer_matchtest__find_paths__exclude_is_relative_to_rootsample/.*case named in the tickettest__find_paths__handles_file_rootThe only pre-existing assertions that changed anywhere are two
to_dict()expectations intest_data_sync.py(test__BatchDataSyncRequest__to_dict,test__PrepareBatchDataSyncResponse__to_dict), which gained"delete": Truebecause the new field serializes.Downstream callers to be aware of in PR-C:
s3.py:727passes userinclude/excludeintofind_pathsand is the call site this change is meant to fix.s3.py:414,765, and1311callfind_pathswith no patterns and hit the unchanged early-return path.BatchDataSyncRequest._handle_single_flattened_requestVerified (scope item 7). It calls
DataSyncRequest.is_valid(data), which round-trips through Pydantic:filter_configdict validates and is wrapped correctly —test__BatchDataSyncRequest__from_dict__flattened_request_with_filter_configDataSyncRequest(source_path/destination_pathare required), so the flattening branch does not misfireOne hazard checked explicitly:
cached_propertyvalues live in the instance__dict__, so I confirmed that touchinginclude_patternsdoes not leak intoto_dict()or break equality — pinned bytest__DataSyncFilterConfig__cached_properties_do_not_leak_into_serialization.Tests
New
test/aibs_informatics_core/utils/test_filters.py(28 tests) covers relative anchoring,fullmatchvs. fragment matching, exclude-beats-include, empty/absent include, multi-pattern OR-ing, compiled-pattern passthrough, S3 URI handling, path-is-root / path-outside-root, and element-type preservation for bothPathandS3Path.test_data_sync.pyadds model round-tripsto_dict()->from_dict()with and withoutfilter_config, including throughBatchDataSyncRequestandPrepareBatchDataSyncResponse— the seam the SFN Map state crosses.make format && make lint && make testall clean: ruff clean, mypy clean over 65 source files, 1092 tests passing.Out of scope
models/demand_execution/**(Resolvable,JobParam, serializer, hash) is untouched — that is PR-B in this same repo. No version bump, no release.🤖 Generated with Claude Code
End-to-end verification (dev)
This PR contributes the
DataSyncFilterConfigmodel, thefilter_root/filter_configfields onDataSyncTask,DataSyncConfig.delete, and the shared fullmatch filter helper to the behavior verified below.Four DemandExecutions were run against the deployed
dev-deenvironment (account051791135335,us-west-2) using a shared 12-object / 541,610-byte S3 fixture. All four Step Functions executions reachedSUCCEEDED, and in every case the set of objects that landed in S3 matches the declared include/exclude filters exactly — no missing matches and no leaked non-matches.Because a single demand execution exercises the whole chain — the data-sync request/filter model in
aibs-informatics-core, the S3 transfer and filtering implementation inaibs-informatics-aws-utils, and the Batch/EFS execution wiring inaibs-informatics-aws-lambda— this same evidence block is attached to every PR in the set rather than split across them.Related PRs
These five PRs are one change set and are intended to merge in release order (R1 first, then R2, then R3), since each release depends on the one before it.
Fixture
s3://dev-de-core-us-west-2-051791135335/test_data/ocsdv-452-filters/input/(the fixture now lives in the environment's own bucket, having been moved off an orphaned bucket that no stack owns, so inputs and outputs share one bucket) — 12 objects, 541,610 bytes total (aws s3 ls --recursive --summarizereportsTotal Objects: 12 / Total Size: 541610):README.mdmetadata.jsonsampleA/aligned.bamsampleA/aligned.bam.baisampleA/qc_summary.txtsampleA/reads_R1.fastqsampleA/reads_R2.fastqsampleB/aligned.bamsampleB/aligned.bam.baisampleB/qc_summary.txtsampleB/reads_R1.fastqsampleB/reads_R2.fastqEach case runs the same container command: list
${INPUT_DATA},cp -R ${INPUT_DATA}/. ${OUTPUT_DATA}/, list${OUTPUT_DATA}. The container itself does no filtering, so any difference between the fixture and the uploaded set is attributable to the data-sync filters.Results
Counts are objects. "In" is the fixture, "localized" is what survived the input filter and was present under
${INPUT_DATA}in the container, "uploaded" is what was observed in S3 under the case prefix.tc1-input-exclude-bamexclude: [".*\\.bam", ".*\\.bam\\.bai"]tc2-input-include-fastqinclude: [".*\\.fastq"]tc3-output-exclude-fastqexclude: [".*\\.fastq"]tc4-both-ends-filteredinclude: ["sampleA/.*"]include: [".*\\.txt"]Across the four cases: 21 objects, 551,275 bytes written under
s3://dev-de-core-us-west-2-051791135335/test_results/ocsdv-452-filters/.Two independent confirmations worth noting:
.fastqfiles and nothing else. Uploaded file sizes are byte-identical to their sources, so nothing was truncated in transit.jobId 7f83fd65-6e9e-4817-a48d-e6e796b1cedf) prints all 12 files under--- localized input (post input-filter) ---and all 12 again under--- staged for upload (pre output-filter) ---, yet only 8 objects reached S3. That rules out the output filter being misapplied at localization time, which an object count alone could not.Note on attribution for tc1 and tc2: because the container copies
${INPUT_DATA}wholesale into${OUTPUT_DATA}, the final S3 state for an input-side filter is indistinguishable from an equivalent output-side filter. For those two cases the input-side attribution rests on the payload (filters declared oninput_data,output_databare) plus the container'sfindoutput, not on the S3 listing alone. tc3 and tc4 are unambiguous.Directory structure is preserved end to end in all cases — the
sampleA/andsampleB/prefixes survive the round trip, so patterns are matched against the same relative path that is used to construct the destination key.tc1-input-exclude-bam — input-side exclude, 8 objects uploaded (9,202 bytes)
Uploaded (relative to
s3://dev-de-core-us-west-2-051791135335/test_results/ocsdv-452-filters/tc1-input-exclude-bam/;aws s3 ls --recursive --summarizereportsTotal Objects: 8 / Total Size: 9202):Correctly not uploaded — these four match one of the two input-side exclude patterns (
.*\.bam,.*\.bam\.bai), so they were never localized and therefore never staged:sampleA/aligned.bam.*\.bamsampleA/aligned.bam.bai.*\.bam\.baisampleB/aligned.bam.*\.bamsampleB/aligned.bam.bai.*\.bam\.baiEvery excluded object matches a declared pattern, and every object matching a declared pattern is excluded. Step Functions execution
d247218f-34e6-47cc-ad4b-a175180b2e45onarn:aws:states:us-west-2:051791135335:stateMachine:dev-de-demand-execution,SUCCEEDED, 2026-08-12 14:46:07 → 14:51:02 (-07:00); object timestamps (14:50:37) fall inside that window.{ "execution_type": "ocsdv452", "execution_id": "ocsdv452-tc1-input-exclude-bam", "execution_image": "public.ecr.aws/ubuntu/ubuntu:22.04", "execution_parameters": { "command": [ "set", "-eu", "&&", "echo", "'=== tc1-input-exclude-bam ==='", "&&", "echo", "'--- localized input (post input-filter) ---'", "&&", "find", "${INPUT_DATA}", "-type", "f", "|", "sort", "&&", "mkdir", "-p", "${OUTPUT_DATA}", "&&", "cp", "-R", "${INPUT_DATA}/.", "${OUTPUT_DATA}/", "&&", "echo", "'--- staged for upload (pre output-filter) ---'", "&&", "find", "${OUTPUT_DATA}", "-type", "f", "|", "sort" ], "params": { "input_data": { "remote": "s3://dev-de-core-us-west-2-051791135335/test_data/ocsdv-452-filters/input/", "local": "input_data", "exclude": [ ".*\\.bam", ".*\\.bam\\.bai" ] }, "output_data": { "local": "output_data", "remote": "s3://dev-de-core-us-west-2-051791135335/test_results/ocsdv-452-filters/tc1-input-exclude-bam/" } }, "inputs": [ "input_data" ], "outputs": [ "output_data" ], "output_s3_prefix": "s3://dev-de-core-us-west-2-051791135335/test_results/ocsdv-452-filters/tc1-input-exclude-bam/" }, "execution_platform": { "aws_batch": { "job_queue_name": "dev-de-demand-on-demand-job-queue" } }, "resource_requirements": { "vcpus": 1, "memory": 2048 } }tc2-input-include-fastq — input-side include, 4 objects uploaded (7,932 bytes)
Uploaded (
Total Objects: 4 / Total Size: 7932; 4 × 1,983 = 7,932, matching source sizes exactly):Correctly not uploaded — the input side declares a single include pattern
.*\.fastqand no exclude, so any key that does not match is not localized. None of these eight keys end in.fastq:All four fixture keys that do match
.*\.fastqare present, so membership is correct in both directions. Step Functions executionarn:aws:states:us-west-2:051791135335:execution:dev-de-demand-execution:ocsdv452-tc2-input-include-fastq,SUCCEEDED, 2026-08-12 15:37:27 → 15:42:09 (-07:00).{ "execution_type": "ocsdv452", "execution_id": "ocsdv452-tc2-input-include-fastq", "execution_image": "public.ecr.aws/ubuntu/ubuntu:22.04", "execution_parameters": { "command": [ "set", "-eu", "&&", "echo", "'=== tc2-input-include-fastq ==='", "&&", "echo", "'--- localized input (post input-filter) ---'", "&&", "find", "${INPUT_DATA}", "-type", "f", "|", "sort", "&&", "mkdir", "-p", "${OUTPUT_DATA}", "&&", "cp", "-R", "${INPUT_DATA}/.", "${OUTPUT_DATA}/", "&&", "echo", "'--- staged for upload (pre output-filter) ---'", "&&", "find", "${OUTPUT_DATA}", "-type", "f", "|", "sort" ], "params": { "input_data": { "remote": "s3://dev-de-core-us-west-2-051791135335/test_data/ocsdv-452-filters/input/", "local": "input_data", "include": [ ".*\\.fastq" ] }, "output_data": { "local": "output_data", "remote": "s3://dev-de-core-us-west-2-051791135335/test_results/ocsdv-452-filters/tc2-input-include-fastq/" } }, "inputs": [ "input_data" ], "outputs": [ "output_data" ], "output_s3_prefix": "s3://dev-de-core-us-west-2-051791135335/test_results/ocsdv-452-filters/tc2-input-include-fastq/" }, "execution_platform": { "aws_batch": { "job_queue_name": "dev-de-demand-on-demand-job-queue" } }, "resource_requirements": { "vcpus": 1, "memory": 2048 } }tc3-output-exclude-fastq — output-side exclude, 8 objects uploaded (533,678 bytes)
Uploaded (
Total Objects: 8 / Total Size: 533678):Correctly not uploaded — the input side is unfiltered, so all 12 objects were localized and all 12 were staged under
${OUTPUT_DATA}. These four were dropped at upload because they match the output-side exclude.*\.fastq:This is the case that distinguishes output-side filtering from input-side filtering by observation rather than by declaration: the container log lists all 12 files at both checkpoints, yet only 8 objects reached S3. Step Functions execution
ocsdv452-tc3-output-exclude-fastq,SUCCEEDED, 2026-08-12 15:38:21 → 15:41:58 (-07:00); Batch job7f83fd65-6e9e-4817-a48d-e6e796b1cedfondev-de-demand-on-demand-job-queue,SUCCEEDED.{ "execution_type": "ocsdv452", "execution_id": "ocsdv452-tc3-output-exclude-fastq", "execution_image": "public.ecr.aws/ubuntu/ubuntu:22.04", "execution_parameters": { "command": [ "set", "-eu", "&&", "echo", "'=== tc3-output-exclude-fastq ==='", "&&", "echo", "'--- localized input (post input-filter) ---'", "&&", "find", "${INPUT_DATA}", "-type", "f", "|", "sort", "&&", "mkdir", "-p", "${OUTPUT_DATA}", "&&", "cp", "-R", "${INPUT_DATA}/.", "${OUTPUT_DATA}/", "&&", "echo", "'--- staged for upload (pre output-filter) ---'", "&&", "find", "${OUTPUT_DATA}", "-type", "f", "|", "sort" ], "params": { "input_data": { "remote": "s3://dev-de-core-us-west-2-051791135335/test_data/ocsdv-452-filters/input/", "local": "input_data" }, "output_data": { "local": "output_data", "remote": "s3://dev-de-core-us-west-2-051791135335/test_results/ocsdv-452-filters/tc3-output-exclude-fastq/", "exclude": [ ".*\\.fastq" ] } }, "inputs": [ "input_data" ], "outputs": [ "output_data" ], "output_s3_prefix": "s3://dev-de-core-us-west-2-051791135335/test_results/ocsdv-452-filters/tc3-output-exclude-fastq/" }, "execution_platform": { "aws_batch": { "job_queue_name": "dev-de-demand-on-demand-job-queue" } }, "resource_requirements": { "vcpus": 1, "memory": 2048 } }tc4-both-ends-filtered — include on both ends, 1 object uploaded (463 bytes)
Uploaded (verbatim from
aws s3 ls ... --recursive):Correctly not uploaded — two stages, in order:
sampleA/.*admits only the 5 objects undersampleA/. Dropped at localization (7 objects):README.mdandmetadata.json(top level, nosampleA/prefix), and all 5sampleB/*objects..*\.txtadmits onlyqc_summary.txtof the 5 that were staged. Dropped at upload (4 objects):sampleA/aligned.bam,sampleA/aligned.bam.bai,sampleA/reads_R1.fastq,sampleA/reads_R2.fastq.Each of the 11 absent files is absent for a reason one of the two filters calls for, and the single present file is the only one both filters admit. The
sampleA/path component survives into the destination key, confirming the include pattern is matched against the same relative path that is preserved on upload. Step Functions executionarn:aws:states:us-west-2:051791135335:execution:dev-de-demand-execution:ocsdv452-tc4-both-ends-filtered,SUCCEEDED, 2026-08-12 15:38:39 → 15:42:23 (-07:00); the object'sLastModifiedfalls inside that window.{ "execution_type": "ocsdv452", "execution_id": "ocsdv452-tc4-both-ends-filtered", "execution_image": "public.ecr.aws/ubuntu/ubuntu:22.04", "execution_parameters": { "command": [ "set", "-eu", "&&", "echo", "'=== tc4-both-ends-filtered ==='", "&&", "echo", "'--- localized input (post input-filter) ---'", "&&", "find", "${INPUT_DATA}", "-type", "f", "|", "sort", "&&", "mkdir", "-p", "${OUTPUT_DATA}", "&&", "cp", "-R", "${INPUT_DATA}/.", "${OUTPUT_DATA}/", "&&", "echo", "'--- staged for upload (pre output-filter) ---'", "&&", "find", "${OUTPUT_DATA}", "-type", "f", "|", "sort" ], "params": { "input_data": { "remote": "s3://dev-de-core-us-west-2-051791135335/test_data/ocsdv-452-filters/input/", "local": "input_data", "include": [ "sampleA/.*" ] }, "output_data": { "local": "output_data", "remote": "s3://dev-de-core-us-west-2-051791135335/test_results/ocsdv-452-filters/tc4-both-ends-filtered/", "include": [ ".*\\.txt" ] } }, "inputs": [ "input_data" ], "outputs": [ "output_data" ], "output_s3_prefix": "s3://dev-de-core-us-west-2-051791135335/test_results/ocsdv-452-filters/tc4-both-ends-filtered/" }, "execution_platform": { "aws_batch": { "job_queue_name": "dev-de-demand-on-demand-job-queue" } }, "resource_requirements": { "vcpus": 1, "memory": 2048 } }Note on the first attempt
The first attempt at these four runs failed before the container started, with an
efs-utilserror reportingFile name too long. The cause was the generated ECS volume name: it made the mount helper's CA database path exceed OpenSSL's 256-byteBSIZEguard by 4 characters. It was worked around for the run above by shorteningexecution_typetoocsdv452. PR-E addresses it properly by condensing the generated volume name from 50 characters to 16, which puts the path back under the limit without relying on short caller-supplied names.Scope
This is a dev-environment functional check of four small cases against a 12-object fixture. It demonstrates that the filter semantics behave as declared on both the input and output sides of a real demand execution; it is not a performance or scale test, and it does not cover large transfers, multipart uploads, or concurrent executions. Verification was read-only (
s3 ls,s3api list-objects-v2,sts get-caller-identity,stepfunctions list/describe-execution,batch list/describe-jobs,logs get-log-events).Addendum: container logs confirm the input filter runs on the download, not just the upload
The S3 result alone cannot fully separate input-side from output-side filtering for
tc1andtc2, because the container copies its input directory wholesale into the output directory — an unfiltered download plus an equivalent output-side exclude would produce the same uploaded set.tc3andtc4disambiguate by construction (tc3uploads the.bamfiles thattc1drops, from the same fixture), but it is worth closing directly.The container prints its localized input before copying. From
/aws/batch/job, streamdev-de-ocsdv452-43c8f938.../bc357a293a09432681668be032cb1cb3(tc1-input-exclude-bam):Eight files, not twelve. The four
.bam/.bam.baiobjects never reached the container's EFSworking directory — the filter was applied during the download, so the 524 KB of alignment data
was never transferred. That is the behavior the feature exists to provide, and it is what
distinguishes filtering from post-hoc pruning.
Only this one stream was still retained in CloudWatch when the logs were pulled, so this direct
confirmation covers
tc1; the other three cases rest on the S3 results and their Step Functionsexecutions above.