Skip to content

CLI

Command-line interface for the LENS grading pipeline.

Usage examples::

python -m grading_pipeline --summary "Patient presents with..." --engine heuristic
python -m grading_pipeline --summary-file note.txt --engine llm --model gpt-4o
python -m grading_pipeline --summary "..." --engine heuristic --format json --pretty

main(argv=None)

CLI entry point. Parses args, runs the pipeline, and prints output.

Returns 0 on success, 2 on input validation errors.

Source code in src/grading_pipeline/cli.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
def main(argv: Sequence[str] | None = None) -> int:
    """CLI entry point.  Parses args, runs the pipeline, and prints output.

    Returns 0 on success, 2 on input validation errors.
    """
    parser = _build_parser()
    args = parser.parse_args(argv)

    try:
        summary = _validate_summary(_resolve_summary(args))
    except ValueError as exc:
        print(str(exc), file=sys.stderr)
        raise SystemExit(2) from exc

    rubric = load_rubric(args.rubric)
    roles = load_roles(args.roles, rubric.dimension_ids)

    result = asyncio.run(
        run_pipeline(
            summary,
            args.engine,
            args.format,
            rubric=rubric,
            roles=roles,
            model=args.model,
            temperature=args.temperature,
            gap_threshold=args.gap_threshold,
            max_retries=2,
        )
    )

    if args.format == "human":
        _print_human(result, rubric)
        return 0

    payload = {
        "summary": summary,
        "rubric_id": rubric.rubric_id,
        **result,
    }

    output = json.dumps(payload, indent=2 if args.pretty else None)
    if args.output:
        Path(args.output).write_text(output)
    print(output)
    return 0