Skip to content

fix: NovaBio Flex2 - do not emit measurements that have no measured value CUST-12697 - #1278

Open
ajcariaga16 wants to merge 1 commit into
mainfrom
aj-novaflex-empty-detection-measurements
Open

ajcariaga16 wants to merge 1 commit into
mainfrom
aj-novaflex-empty-detection-measurements

Conversation

@ajcariaga16

Copy link
Copy Markdown
Collaborator

Summary

Converting a NovaBio BioProfile Flex2 SampleResults CSV still fails schema validation after #1261 whenever a row has no cell counts but either (a) a Cell Density Dilution value, or (b) the file has a unit row, which sets the cell density / PO2 / PCO2 unit strings on every sample. Reported by a customer (CUST-12475, follow-up to the pH-only failure fixed in #1261).

Root cause

_get_measurements() emitted a measurement for a detection type whenever any of its mapped properties was non-None:

if any(value is not None for value in kwargs.values()):

That includes *_unit fields and the data processing fields (cell_type_processing_method, cell_density_dilution_factor), none of which are measured values. A chemistry-only row then produced a cell-counting measurement with no processed data (or only a cell density dilution factor), and the cell-counting schema requires viability (cell counter) and viable cell density (cell counter):

Failed to validate allotrope model against schema: {'device control aggregate document': {'device control document': [{'detection type': 'cell-counting', ...}]}, ..., 'processed data aggregate document': {'processed data document': [{'data processing document': {'cell density dilution factor': {'value': 1.0, 'unit': '(unitless)'}}}]}} is not valid under any of the given schemas

An empty analyte list ([]) was also counted as a value, producing a metabolite measurement with no analyte document.

Fix

Add MEASURED_PROPERTIES_BY_DETECTION_TYPE listing the measured-value properties of each detection type, and only emit a measurement when at least one of them is present. This generalizes the pH-only guard from #1261 (REQUIRED_PROPERTY_BY_DETECTION_TYPE), which it replaces: pH remains the only measured property of ph-detection, since vessel temperature is the temperature at which pH was measured rather than a measurand.

Behavior for rows that do have measured values is unchanged. A row with partial cell counts (e.g. total density without viability) still fails validation as before; that is inconsistent data and dropping it silently seemed worse than a clear error.

Testing

  • New fixture SampleResultsT000000001C2026-01-01_120000.csv (anonymized, derived from the customer file) with a unit row and three rows: full cell counts, chemistry-only, and dilution-setting-only. Without the fix it fails with the error above; expected JSON generated with --overwrite.
  • New parametrized structure tests covering unit-only, dilution-only, empty-analyte and present-value cases, plus a check that measured properties are a subset of the mapped properties.
  • The customer's 12-sample file converts successfully with this change.
  • hatch run test_all.py3.10:pytest tests: 1538 passed. ruff, black --check and mypy clean on the changed files.

🤖 Generated with Claude Code

…alue

A detection measurement was emitted whenever any mapped property was set,
including unit strings from the file's unit row and cell density dilution
settings. Rows without cell counts then produced an empty cell-counting
measurement that fails ASM schema validation (viability and viable cell
density are required), aborting the whole file.

Only emit a measurement when at least one measured value of its detection
type is present; units, data processing settings and the pH measurement
temperature alone do not count, and an empty analyte list counts as no value.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ajcariaga16 ajcariaga16 changed the title fix: NovaBio Flex2 - do not emit measurements that have no measured value eng: NovaBio Flex2 - do not emit measurements that have no measured value CUST-12697 Oct 19, 2026
@ajcariaga16
ajcariaga16 marked this pull request as ready for review October 19, 2026 14:54
@ajcariaga16
ajcariaga16 requested review from a team and slopez-b as code owners October 19, 2026 14:54
@ajcariaga16 ajcariaga16 changed the title eng: NovaBio Flex2 - do not emit measurements that have no measured value CUST-12697 fix: NovaBio Flex2 - do not emit measurements that have no measured value CUST-12697 Oct 19, 2026
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.

2 participants