Skip to content

OCSDV-453 (PR-B): demand execution include/exclude filters + hash-stable serializer - #55

Merged
rpmcginty merged 5 commits into
feature/OCSDV-452-data-sync-filter-modelsfrom
feature/OCSDV-453-demand-execution-filters
Aug 14, 2026
Merged

rpmcginty merged 5 commits into
feature/OCSDV-452-data-sync-filter-modelsfrom
feature/OCSDV-453-demand-execution-filters

Conversation

@rpmcginty

@rpmcginty rpmcginty commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

Jira: OCSDV-453 — PR-B of 5, release R1.

Important

Based on feature/OCSDV-452-data-sync-filter-models (#54), not main. PR-B reuses DataSyncFilterConfig, which #54 introduces and which is not yet on main. GitHub will retarget this to main automatically once #54 merges; the diff below is PR-B's changes only. Merge #54 first.

This is the aibs-informatics-core half of OCSDV-453 — the risky half. No version bump; core releases once, after this lands.

The problem

A filter set on a param has to survive four hops to reach a sync request, and each one drops what it doesn't explicitly know about. The last hop is the trap: sanitize_serialized_params collapses a Resolvable to "remote @ local" via to_str(), and since DemandExecution crosses the state machine boundary as JSON, anything lost there is gone for good.

What's here

1. ResolvableBase.include / .exclude

Flat fields, matching the wire format in the ticket:

{"remote": "s3://bucket/run1/", "local": "aligned", "exclude": [".*\\.bam"]}

A filter_config property re-exposes them as the DataSyncFilterConfig the sync layer consumes — that's where the reuse lives, while the user-facing JSON stays flat. The wrapping @model_serializer (injects action) and @model_validator (pops it) keep working; to_dict() already runs exclude_none=True, so unfiltered resolvables serialize exactly as before.

2. Filters on the job param dataclasses

ResolvableJobParam (and its Downloadable/Uploadable subclasses) gain the fields. _param_to_job_params__build_input / __build_output now route through from_resolvable instead of rebuilding positionally from local/remote, so the dataclass hop stops truncating.

3. The conditional serializer — the load-bearing bit

params[k] = v.to_dict() if v.has_filters() else v.to_str()

This conditional is the entire backwards-compatibility mechanism. get_execution_hash hashes the sanitized params, and that hash drives job_definition_name (strict=False) and job_name (strict=True) for every demand execution in the system. Emitting the dict form unconditionally would change the hash of every unfiltered execution and silently re-register every existing job definition.

has_filters() treats an empty list as no filter for the same reason — an empty exclude: [] would otherwise force the dict form, and a new hash, while filtering nothing.

Hash regression testing

test_filters.py pins a fixed payload and asserts literal hash strings captured by running get_execution_hash against that payload on the commit before this change. A computed expectation would drift silently alongside the regression it's meant to catch, so the values are hardcoded.

Both param forms are pinned, because they take different paths through the serializer:

Form strict=True strict=False
plain dicts in params ca65e415…4e76 44a99a39…661c
Resolvable objects in params (the to_str() path) f60365ce…2026 44a99a39…661c

Also asserted: a filtered execution hashes differently from the otherwise-identical unfiltered one, and empty/None filters do not perturb the hash.

Verified by mutation — replacing the conditional with an unconditional to_dict() fails 5 tests, including both pinned hashes. The guard bites.

Round trips

to_dict() → from_dict() covered with and without filters, for both dict-form and Resolvable-object params, asserting filters survive intact and that no include/exclude keys leak into unfiltered output.

resolve_references does not mangle patterns (ticket checklist item)

Confirmed, and now enforced. JobParamResolver.resolve_references substitutes ${...} over value and remote_value via find_references() / replace_references(). Filter patterns are deliberately kept out of both, and out of __hash__ — they're literal data, not templated values, and regex syntax legitimately contains $, { and }.

Tests round-trip patterns chosen to be hostile to that substitution, alongside a param that does resolve a real reference:

  • ^data/\d{2}/.*$ — brace quantifier and anchors
  • .*\{tmp\}.* — literal braces
  • sample_[A-Z]{1,3}\$.* — dollar plus quantifier
  • (?:a|b){2,}\$\{NOT_A_REF\} — an escaped ${...} lookalike

Caveat worth carrying into PR-E

On an Uploadable, output filtering means "do not upload", not "keep locally" — post_execution_data_sync_requests sets retain_source_data=False and cleanup_working_dir defaults to True, so excluded outputs are still deleted from EFS. Documented on ResolvableBase.

Out of scope

models/data_sync.py and utils/filters.py are untouched — PR-A owns those. The diff is three source files plus one new test file.

Testing

make format && make lint && make test all clean — ruff, mypy (65 files), and 1131 tests passing, with no existing test modified.

🤖 Generated with Claude Code


End-to-end verification (dev)

This PR contributes the include/exclude filters on ResolvableBase / ResolvableJobParam and the hash-stable conditional serializer that carries them through to the sync requests exercised below.

Four DemandExecutions were run against the deployed dev-de environment (account 051791135335, us-west-2) using a shared 12-object / 541,610-byte S3 fixture. All four Step Functions executions reached SUCCEEDED, 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 in aibs-informatics-aws-utils, and the Batch/EFS execution wiring in aibs-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.

PR Repository / number Release Link
PR-A aibs-informatics-core#54 R1 (core) #54
PR-B aibs-informatics-core#55 R1 (core) #55
PR-C aibs-informatics-aws-utils#47 R2 (aws-utils) AllenInstitute/aibs-informatics-aws-utils#47
PR-D aibs-informatics-aws-lambda#40 R3 (aws-lambda) AllenInstitute/aibs-informatics-aws-lambda#40
PR-E aibs-informatics-aws-lambda#41 R3 (aws-lambda) AllenInstitute/aibs-informatics-aws-lambda#41

Fixture

s3://dev-de-core-us-west-2-051791135335/test_data/ocsdv-452-filters/input/ (moved here from an orphaned bucket that no CloudFormation stack owns, so the fixture now lives in the environment's own bucket and inputs and outputs share one bucket) — 12 objects, 541,610 bytes total (aws s3 ls --recursive --summarize reports Total Objects: 12 / Total Size: 541610):

Key Bytes
README.md 130
metadata.json 214
sampleA/aligned.bam 262,140
sampleA/aligned.bam.bai 4,064
sampleA/qc_summary.txt 463
sampleA/reads_R1.fastq 1,983
sampleA/reads_R2.fastq 1,983
sampleB/aligned.bam 262,140
sampleB/aligned.bam.bai 4,064
sampleB/qc_summary.txt 463
sampleB/reads_R1.fastq 1,983
sampleB/reads_R2.fastq 1,983

Each 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.

Case Input filter Output filter In → localized → uploaded Uploaded bytes Result
tc1-input-exclude-bam exclude: [".*\\.bam", ".*\\.bam\\.bai"] none 12 → 8 → 8 9,202 PASS
tc2-input-include-fastq include: [".*\\.fastq"] none 12 → 4 → 4 7,932 PASS
tc3-output-exclude-fastq none exclude: [".*\\.fastq"] 12 → 12 → 8 533,678 PASS
tc4-both-ends-filtered include: ["sampleA/.*"] include: [".*\\.txt"] 12 → 5 → 1 463 PASS

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:

  • Byte arithmetic closes. tc1: 9,202 uploaded + 532,408 excluded (2 × (262,140 + 4,064)) = 541,610 = the fixture total. tc3: 541,610 − 533,678 = 7,932 = 4 × 1,983, exactly the four .fastq files and nothing else. Uploaded file sizes are byte-identical to their sources, so nothing was truncated in transit.
  • tc3 isolates the filter to the upload step. The Batch container log for tc3 (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 on input_data, output_data bare) plus the container's find output, not on the S3 listing alone. tc3 and tc4 are unambiguous.

Directory structure is preserved end to end in all cases — the sampleA/ and sampleB/ 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 --summarize reports Total Objects: 8 / Total Size: 9202):

README.md
metadata.json
sampleA/qc_summary.txt
sampleA/reads_R1.fastq
sampleA/reads_R2.fastq
sampleB/qc_summary.txt
sampleB/reads_R1.fastq
sampleB/reads_R2.fastq

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:

Key Excluded by
sampleA/aligned.bam .*\.bam
sampleA/aligned.bam.bai .*\.bam\.bai
sampleB/aligned.bam .*\.bam
sampleB/aligned.bam.bai .*\.bam\.bai

Every excluded object matches a declared pattern, and every object matching a declared pattern is excluded. Step Functions execution d247218f-34e6-47cc-ad4b-a175180b2e45 on arn: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):

sampleA/reads_R1.fastq
sampleA/reads_R2.fastq
sampleB/reads_R1.fastq
sampleB/reads_R2.fastq

Correctly not uploaded — the input side declares a single include pattern .*\.fastq and no exclude, so any key that does not match is not localized. None of these eight keys end in .fastq:

README.md
metadata.json
sampleA/aligned.bam
sampleA/aligned.bam.bai
sampleA/qc_summary.txt
sampleB/aligned.bam
sampleB/aligned.bam.bai
sampleB/qc_summary.txt

All four fixture keys that do match .*\.fastq are present, so membership is correct in both directions. Step Functions execution arn: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):

README.md
metadata.json
sampleA/aligned.bam
sampleA/aligned.bam.bai
sampleA/qc_summary.txt
sampleB/aligned.bam
sampleB/aligned.bam.bai
sampleB/qc_summary.txt

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:

sampleA/reads_R1.fastq
sampleA/reads_R2.fastq
sampleB/reads_R1.fastq
sampleB/reads_R2.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 job 7f83fd65-6e9e-4817-a48d-e6e796b1cedf on dev-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):

2026-08-12 15:41:52        463 test_results/ocsdv-452-filters/tc4-both-ends-filtered/sampleA/qc_summary.txt

Correctly not uploaded — two stages, in order:

  1. Input include sampleA/.* admits only the 5 objects under sampleA/. Dropped at localization (7 objects): README.md and metadata.json (top level, no sampleA/ prefix), and all 5 sampleB/* objects.
  2. Output include .*\.txt admits only qc_summary.txt of 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 execution arn: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's LastModified falls 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-utils error reporting File name too long. The cause was the generated ECS volume name: it made the mount helper's CA database path exceed OpenSSL's 256-byte BSIZE guard by 4 characters. It was worked around for the run above by shortening execution_type to ocsdv452. 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 tc1 and tc2, 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. tc3 and tc4 disambiguate by construction (tc3 uploads the .bam files that tc1 drops, from the same fixture), but it is worth closing directly.

The container prints its localized input before copying. From /aws/batch/job, stream
dev-de-ocsdv452-43c8f938.../bc357a293a09432681668be032cb1cb3 (tc1-input-exclude-bam):

=== tc1-input-exclude-bam ===
--- localized input (post input-filter) ---
.../input_data/README.md
.../input_data/metadata.json
.../input_data/sampleA/qc_summary.txt
.../input_data/sampleA/reads_R1.fastq
.../input_data/sampleA/reads_R2.fastq
.../input_data/sampleB/qc_summary.txt
.../input_data/sampleB/reads_R1.fastq
.../input_data/sampleB/reads_R2.fastq

Eight files, not twelve. The four .bam/.bam.bai objects never reached the container's EFS
working 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 Functions
executions above.

Filters set on a param in DemandExecutionParameters.params previously died at
one of four hops between user input and the data sync request, because every
hop drops anything it does not explicitly know about. This carries them the
whole way:

  * ResolvableBase gains include/exclude, plus a filter_config property that
    re-exposes them as the DataSyncFilterConfig the sync layer consumes. The
    wire format stays flat ({"remote": ..., "local": ..., "exclude": [...]}),
    and the wrapping model_serializer/model_validator pair that injects and
    pops `action` keeps working.
  * ResolvableJobParam (and its Downloadable/Uploadable subclasses) carry the
    fields, so the plain-dataclass hop no longer truncates to name/value/
    remote_value. _param_to_job_params__build_input/__build_output now route
    through from_resolvable rather than rebuilding positionally.
  * sanitize_serialized_params emits to_dict() for a Resolvable only when
    filters are present, and to_str() otherwise.

That last conditional is the entire backwards-compatibility mechanism, not a
stylistic choice. get_execution_hash hashes the *sanitized* params, and that
hash drives job_definition_name (strict=False) and job_name (strict=True) for
every demand execution. Serializing the dict form unconditionally would change
the hash of every unfiltered execution in the system and silently re-register
every existing job definition. has_filters() treats an empty list as no filter
for the same reason -- it would otherwise force the dict form while filtering
nothing.

test_filters.py pins a fixed payload against hashes captured before this
change, for both the dict-param and Resolvable-object forms, so a regression
fails loudly instead of drifting. Verified by mutation: making the conditional
unconditional fails the pinned assertions.

Filter patterns are deliberately kept out of find_references() and __hash__.
Reference resolution substitutes ${...} over param values, and regex syntax
legitimately contains $, { and } -- scanning filters risks mangling a valid
pattern. Covered by tests over patterns like ^data/\d{2}/.*$ and
(?:a|b){2,}\$\{NOT_A_REF\}.

Note for callers: on an Uploadable, filtering means "do not upload", not
"keep locally" -- excluded outputs are still cleaned off EFS.

Refs OCSDV-453 (PR-B).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@rpmcginty
rpmcginty requested a review from a team August 7, 2026 22:13
@rpmcginty

Copy link
Copy Markdown
Collaborator Author

PR #55 changes 4 files with +504/−5 LOC. Of the additions, 407 lines (81%) are tests, 67 lines (13%) are production docstrings, and 28 lines (6%) are functional production code. The functional changes add include/exclude filter fields and adapters, propagate filters through job parameters, and conditionally serialize filtered resolvables while preserving legacy hashes for unfiltered executions. No standalone documentation files are changed.

Change category Added Deleted Description
Functional production code 28 4 Filter fields, propagation, configuration adapter, and hash-stable serialization
Production docstrings/comments 69 1 Documentation of filter behavior, regex handling, and hash compatibility
Tests 407 0 Hash regressions, serialization, round trips, filter propagation, and regex safety
Standalone documentation 0 0 No documentation files changed
Total 504 5 4 files changed

@rpmcginty
rpmcginty requested review from njmei and schristinelin and a lite review from Copilot August 12, 2026 00:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends demand-execution “resolvable” parameters to carry per-parameter include/exclude filters end-to-end (wire format → job params → serialized execution JSON) while preserving execution-hash stability for unfiltered executions.

Changes:

  • Added include/exclude fields to ResolvableBase and propagated them through ResolvableJobParam construction (from_resolvable) so the dataclass hop no longer truncates filters.
  • Updated DemandExecutionParameters.sanitize_serialized_params to conditionally serialize resolvables as to_str() when unfiltered vs to_dict() when filtered to preserve backwards-compatible hashing.
  • Added a comprehensive new test suite that pins pre-change execution hashes and verifies round-trips and reference-resolution behavior with “hostile” regex patterns.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/aibs_informatics_core/models/demand_execution/test_filters.py New regression and round-trip tests to pin hash stability and verify filter carriage/reference behavior.
src/aibs_informatics_core/models/demand_execution/resolvables.py Adds flat include/exclude filter fields and exposes them via filter_config/has_filters().
src/aibs_informatics_core/models/demand_execution/parameters.py Uses from_resolvable() for job params and conditionally serializes filtered resolvables to dict to preserve filter data without breaking legacy hashes.
src/aibs_informatics_core/models/demand_execution/job_param.py Extends ResolvableJobParam with include/exclude, ensures references are not scanned/replaced in filter patterns, and exposes filter_config.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

They sit next to the path they filter rather than in a nested object so the
wire format stays flat::

{"remote": "s3://bucket/run1/", "local": "aligned", "exclude": [".*\\\\.bam"]}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copilot AI review requested due to automatic review settings August 12, 2026 22:13
@codecov

codecov Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.17%. Comparing base (e8b26a9) to head (49f91c1).

Files with missing lines Patch % Lines
...ormatics_core/models/demand_execution/job_param.py 88.88% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                              Coverage Diff                              @@
##           feature/OCSDV-452-data-sync-filter-models      #55      +/-   ##
=============================================================================
+ Coverage                                      97.09%   97.17%   +0.07%     
=============================================================================
  Files                                             58       58              
  Lines                                           3412     3428      +16     
  Branches                                         391      391              
=============================================================================
+ Hits                                            3313     3331      +18     
+ Misses                                            54       53       -1     
+ Partials                                          45       44       -1     
Files with missing lines Coverage Δ
...rmatics_core/models/demand_execution/parameters.py 97.60% <100.00%> (ø)
...matics_core/models/demand_execution/resolvables.py 95.80% <100.00%> (+1.73%) ⬆️
...ormatics_core/models/demand_execution/job_param.py 95.83% <88.88%> (+0.37%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

exclude: str | list[str] | None = None

@property
def filter_config(self) -> DataSyncFilterConfig | None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is a weird question, what happens if we add another filter field to DataSyncFilterConfig but not to this base class? it seems like this class manually builds the filter_config part every time it gets called.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm rereading this I feel like my comment didn't make sense. I was thinking two things:

  1. The DataSyncFilterConfig class doesn't have the new filter field, it's manually constructed here.
  2. This ResolvableBase, along with the ResolveableJobParam class, seem to be doing the same thing with the filters. I'm wondering if there's a way to propagate the filter fields so they're not being constructed twice within two classes

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I considered nesting the DataSyncFilterConfig field but I held off for a few reasons.

  • include/exclude read as resolvable concepts
  • nesting the filter config model couples these models to the data sync schema. This is not terrible, but I want to try to keep decoupled for now.

At this point I can't think of many other filter configuration fields that I would want to add. Instead, I'd rather defer the fuller consolidation (making it a nested filter_config field) to a later date if and when we think of a scenario. I believe it should be easy enough to migrate to such a model without causing a breaking change with the help of pydantic.

Comment on lines +150 to +151
include: str | list[str] | None = None
exclude: str | list[str] | None = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this comment about the manual construction of filters is a true concern, would it be better to do:

Suggested change
include: str | list[str] | None = None
exclude: str | list[str] | None = None
filter_config: DataSyncFilterConfig | None = None

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote above about the reason for not going with your suggested approach. I felt like the simplicity of the flat structure was preferable because it avoids coupling, and these concepts naturally live at the resolvable class. I am also confident that if we do need to expand fields, we can migrate to a nested structure without backwards incompatible changes

@schristinelin schristinelin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one question about how the filter param is getting constructed. I do think we can handle them in a follow up PR even if it's indeed a cause for concern down the road

Copilot AI review requested due to automatic review settings August 14, 2026 02:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

rpmcginty added a commit that referenced this pull request Aug 14, 2026
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>
rpmcginty and others added 2 commits August 13, 2026 20:39
Review feedback (schristinelin on #55): ResolvableBase and ResolvableJobParam
each hand-built a DataSyncFilterConfig and each re-derived "are these filters
filtering anything" -- and did it differently (`bool(x) or bool(y)` vs
`not x and not y`). Both now delegate to from_patterns, so the rule and the
construction each exist once. ResolvableJobParam also gains has_filters() for
symmetry.

include/exclude deliberately stay flat fields on these models rather than
nesting DataSyncFilterConfig. They are resolvable-level concepts -- a resolvable
describes what to move, and filters narrow what to move -- and keeping them flat
keeps the demand execution models independent of the data sync schema. The
property is the boundary translation. A parity test in PR-A fails if
DataSyncFilterConfig grows a field, and carries the migration note.

Also corrects the rationale on sanitize_serialized_params. It claimed that
emitting the dict form unconditionally would silently re-register every job
definition. That is wrong: params are hashed only under strict=True, and
job_definition_name uses get_execution_hash(strict=False), which covers only
execution_type, execution_image and command. The exposed value is job_name.
Verified by comparing hashes against the pre-filter baseline, where the
non-strict hash is identical across every variant.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 03:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@rpmcginty
rpmcginty merged commit 770ed14 into main Aug 14, 2026
9 checks passed
@rpmcginty
rpmcginty deleted the feature/OCSDV-453-demand-execution-filters branch August 14, 2026 04:28
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.

4 participants