Skip to main content

task

Prefect task for the fluid volume calculation step.

Calls compute_fluid_metrics_for_scan from steps.fluid_calculation.functions to compute total fluid volume, lesion volumes, image-centre distance, and CNV probability for each scan from pathology model predictions.

Runs in background mode: an in-memory result does not cross the phase boundary, so the per-file metrics are persisted to the fluid_calculation cache table (keyed by (task_hash, file_id), project_id provenance-only) and a downstream step reads them via the fluid_calculation.cache accessor.

Module

Functions

fluid_calculation_task

def fluid_calculation_task(    datasource: BaseSource,    config: FluidCalculationConfig,    pathology_predictions: CacheAccessor,    filenames: list[str],    cache: CacheProtocol,    task_hash: str,    project_id: str | None = None,    run_id: str | None = None,)> FluidCalculationResult:

Compute fluid volume metrics for each file and persist them to cache.

Arguments

  • datasource: The datasource providing DICOM metadata (slice thickness, pixel spacing row/column) for each file.
  • config: Fluid calculation configuration.
  • pathology_predictions: Cache accessor for pathology model inference results (background step ga_inference.cache).
  • filenames: List of file IDs to process.
  • cache: Cache instance to persist the fluid metrics into.
  • task_hash: Partition key for the fluid_calculation table; a config change lands in a fresh partition.
  • project_id: Provenance only — the project that triggered this run. NOT part of the cache key: rows are keyed by (task_hash, file_id) so two projects on the same datasource share them.
  • run_id: Optional provenance run ID.

Returns FluidCalculationResult carrying the number of rows persisted and a CacheAccessor scoped to this task_hash (fluid_calculation.cache).