Skip to main content

task

Prefect task for the scan_filter step.

The first interactive step in the v9 Granite DAG: takes the full input file list ($file_metadata.cache) and returns the "latest scan per patient" subset (or the input unchanged for the "all" strategy). Every downstream calc/report step keys off this step's filenames output instead of $file_metadata.cache, so the reduction happens once at the calc boundary.

Calls the pure filter_latest_scans function in steps.scan_filter.functions (ported from the v8 _LatestFilterStrategy.apply).

Module

Functions

scan_filter_task

def scan_filter_task(    datasource: BaseSource,    config: ScanFilterConfig,    filenames: list[str],)> ScanFilterResult:

Filter the input file list down to the latest scan per patient.

Arguments

  • datasource: The datasource providing per-file metadata (date and patient identifier columns) used by the "latest" strategy.
  • config: Scan filter configuration.
  • filenames: List of file IDs to filter (typically wired from $file_metadata.cache).

Returns ScanFilterResult with the filtered filenames.

An invalid strategy is rejected up-front by ScanFilterConfig (pydantic), so the strategy here is always a valid ScanFilterStrategy.