feat(py): uv-managed polars data layer with pytest setup #3
Loading…
Reference in a new issue
No description provided.
Delete branch "fm/dse-security-reports-pyproject"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The report pipeline needs a proper Python project for its data frame queries.
This change adds a uv-managed package (
pyproject.toml+ committeduv.lock) with the newest polars release (2.1.0) as the data frame engine and a pytest test setup driven by just recipes.A first polars derivation module reads both Defender export shapes (plus the triage sidecar) and produces exactly the same canonical per-finding JSON as the stdlib
scripts/derive_findings.py, so the two paths cross-check byte-for-byte on the synthetic fixture.What changed
pyproject.toml- new uv-compatible package (src layout, hatchling) pinningpolars==2.1.*and pytest in thetestdependency group.uv.lock- committed lock for reproducible installs (uv sync --locked).src/dse_security_reports/derive.py- polars derivation: reads both export shapes as strings, merges the triage sidecar, resolves resource groups fromconfig/systems.csv(with the optionalsystems-az.csvoverride), and emits the same canonical payload (importance sort, per-system/per-CVE dispatch structure, aggregates) as the stdlib path.src/dse_security_reports/__init__.py- public API of the data layer.src/dse_security_reports/__main__.py- CLI mirroringscripts/derive_findings.py [samples-dir] [out-dir], writing to.local/derived-polars/.src/dse_security_reports/py.typed- typed package marker.tests/conftest.py- session fixtures: synthetic fixture generation and the stdlib reference derivation.tests/test_derive.py- 8 tests on synthetic data only: byte-identical output vs the stdlib derivation, deterministic across runs, payload/finding key order, importance sort, triage merge, system resolution, synthetic-marker semantics.Justfile- appended recipes:install(uv sync),test(pytest),py-derive,py-repro(byte-identical across two runs),py-crosscheck(stdlib vs polars)..gitignore- ignore.venv/and Python bytecode.AGENTS.md- one-line pointer to the data layer and its recipes.Behaviour change
The jq/stdlib pipeline is unchanged; all additions are new files plus appended just recipes.
A new parallel derivation path exists (
just py-derive), proven byte-identical to the stdlib path on the fixture (just py-crosscheck) and byte-stable across runs (just py-repro);just install/just testgive the Python side a reproducible environment and test suite.Instructions-PR: none