Skip to content

fix(flow-cytometry-referee): run_qc entry point, exit status, pinned packages, range-limit check - #1

Open
faranm-stack wants to merge 3 commits into
AzizMuminov:flow-cytometry-refereefrom
faranm-stack:fix/pr162-flow-qc-runner
Open

faranm-stack wants to merge 3 commits into
AzizMuminov:flow-cytometry-refereefrom
faranm-stack:fix/pr162-flow-qc-runner

Conversation

@faranm-stack

@faranm-stack faranm-stack commented Oct 28, 2026 •

Copy link
Copy Markdown

Summary

Fixes the two integration issues from the microsoft#162 review and a range-check bug found while testing real instrument files. The agent now calls a single flow_qc_utils.run_qc(fcs_path, output_dir) function, and the flow-qc launcher exits with Python's status. The declared-range check now counts events at the instrument maximum ($PnR - 1).

Type of change

  • New agent (under agents/<name>/)
  • Update to an existing agent
  • New starter kit (under starter-kits/<name>/)
  • Update to an existing starter kit
  • Schema change (docs/schemas/**)
  • Workflow / script change (.github/**)
  • Documentation only
  • Other (describe below)

Related issue / tracking

Refs microsoft#162

Schema impact

  • No schema changes
  • Schema changes are backward compatible
  • Schema changes are breaking — add the breaking-change label and link the rollout plan below

Validation checklist

  • Documentation (README.md, schemas) is updated to match the change.
  • No hand-edits to .auto-registry/** (it is generated post-merge).
  • No OS / editor artefacts committed (.DS_Store, .env, *.swp, .idea/, .vs/, etc.).
  • If model-weight files are added, they are Git-LFS tracked, ≤5 GB each, and in an allowed format. (None added.)
  • No secrets, customer data, or internal-only URLs are committed.
  • All Markdown links resolve.

Reviewer notes (optional)

Changes (3 commits)

  • eee9b32: new run_qc loads one FCS file and writes <stem>_qc_report.json, <stem>_channel_summary.csv and <stem>_dashboard.png. A file with no events raises a clear ValueError. agent.yaml shows the exact call, and tool.yaml keeps Python's exit status (_EXIT=$? / exit $_EXIT, as in cp2k).
  • 582001d: pins the six Python packages in the Dockerfile to the versions tested here (FlowIO 1.4.0, Matplotlib 3.11.2, NumPy 2.5.4, pandas 3.1.0, scikit-learn 1.9.1, SciPy 1.18.1).
  • a713475: the declared-range fraction compared values with $PnR, but $PnR counts the possible values, so instruments record their maximum as $PnR - 1. It now counts values at or above $PnR - 1. The dashboard samples events evenly across the whole run instead of plotting only the first 20,000. The README documents raw values and the file types the tool rejects.

Validation (fork CI run on a713475)

  • Tool tests with the pinned packages: 9 passed. The launcher tests fail against the original tool.yaml (exit 0 instead of 1 and 3).
  • Built image: the documented run_qc snippet writes the JSON, CSV and PNG for a 100-event synthetic FCS (FITC-A median 50.5). The script the agent generated in Studio on Oct 7 now exits 1 with its TypeError. A zero-event FCS exits 1 with "contains no events".
  • Six public instrument files from FlowIO's sample data (BSD-3-Clause, downloaded at run time): all processed, with event counts matching FlowIO. Before a713475, the range fraction was 0 for every channel; for example, 782 SSC-H events sit at 1023 in 3FITC_4PE_004.fcs, and 247 SSC-A events sit at the maximum in G11.fcs. It now matches the count at $PnR - 1 on every channel.
  • python .github/scripts/validate_pr.py on all agents/flow-cytometry-referee files: passed.
  • Discovery Studio (PRValidation), with an agent and tool built from this branch: a fresh agent-led run on the a713475 image, with the same prompt and file as the failed Oct 7 run, called only run_qc. It reported 100 events and FITC-A median 50.5, and shared the outputs. A deliberately failing script shows as a failed run (exit code 1); tool.yaml has not changed since that test.

Not covered

  • Files with several data sets (such as Beckman Coulter LMD) and files whose HEADER and TEXT give different DATA offsets fail with a clear error; this is now documented.
  • The present_valid and acquisition-rate CV questions from the review are unchanged; those decisions are yours.

…xit status

- Add flow_qc_utils.run_qc(fcs_path, output_dir), which loads one FCS file and
  writes the JSON report, channel-summary CSV, and dashboard. The agent now
  calls only this function. A fresh Studio run failed because the generated
  script called build_qc_report() without the events argument.
- Capture Python's exit status in the flow-qc launcher before tail runs, so a
  failed script no longer exits 0 (same pattern as cp2k).
- Add tests for run_qc, a file without events, and launcher exit codes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the needs-human-review Awaiting human approval label Oct 28, 2026
faranm-stack and others added 2 commits October 28, 2026 18:07
Pin the six direct dependencies to the versions the fix was tested with
(CI and Discovery Studio). load_fcs depends on FlowIO's channel API, so an
unpinned rebuild could break file loading.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- The declared-range fraction compared values with $PnR, but $PnR counts the
  possible values, so instruments record their maximum as $PnR - 1. On public
  FlowIO sample files the tool reported 0 for channels with hundreds of events
  at the maximum (for example, 782 SSC-H events at 1023 in 3FITC_4PE_004.fcs).
  Count values at or above $PnR - 1 instead, and add a regression test.
- Sample dashboard events evenly across the whole acquisition instead of
  plotting only the first 20,000, and add a test.
- Document that values are raw and that multi-data-set files and files with
  HEADER/TEXT DATA offset discrepancies are rejected with an error.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@faranm-stack faranm-stack changed the title fix(flow-cytometry-referee): add run_qc entry point and keep script exit status fix(flow-cytometry-referee): run_qc entry point, exit status, pinned packages, range-limit check Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-human-review Awaiting human approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant