Skip to content

ci(health): bump pyscn to 1.32.4 and read its snake_case report - #451

Merged
thodson-usgs merged 2 commits into
DOI-USGS:mainfrom
thodson-usgs:chore/bump-pyscn
Oct 13, 2026
Merged

thodson-usgs merged 2 commits into
DOI-USGS:mainfrom
thodson-usgs:chore/bump-pyscn

Conversation

@thodson-usgs

@thodson-usgs thodson-usgs commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #415. The pyscn author raised two points in that issue: we analyzed the package twice to get both report formats, and our sanity check would read pyscn's JSON with the old key names after an upgrade.

Change

  • Pin: pyscn==1.32.4, up from 1.29.0, in the [health] extra.

  • One run: pyscn analyze --json --html --no-open dataretrieval writes both reports, replacing the two separate runs.

  • Sanity step:

    • It reads the snake_case keys that pyscn 1.30.0 introduced (system.summary.project_root, total_dependencies, total_modules).
    • A missing key is named in the summary rather than raising to stderr, so a future rename shows up instead of dropping the line.
    • It warns separately when the root is not the checkout and when pyscn analyzed fewer than 90% of the package's .py files.
    • It does not use pyscn's new unresolved_imports count. Under a wrong root, pyscn counts the package's own imports as external, so the count stays 0. A copy of the package analyzed under another root gave 15 modules, 5 dependencies and 0 unresolved imports.
  • .pyscn-known-clones.json is regenerated with 1.32.4. Two defaults changed in pyscn: clone grouping went from connected to complete_linkage, and min_lines from 10 to 8. As a result, 1.32.4 no longer reports the NGWMN, NWIS and WQP getter families as clone groups. It reports two new small pairs instead, the _validation checks reject_together/require_any_of and NWDC's _validate_county/_validate_huc, each recorded with a rationale.

    The file was already out of date: 1.29.0 reports 10 groups on today's main, while the file recorded 5.

    The file also changes in these ways:

    • default_thresholds records group_mode, group_threshold, skip_docstrings and clone_types.
    • The 2026-08-09 docstring measurements are marked as 1.29.0 only, because 1.32.4 skips docstrings.
    • The Water Data rationales no longer cite docstrings.
    • The marginal type-4 pair (similarity 0.672) has its own rationale.
  • Docs: pyproject.toml and CONTRIBUTING.md now list the new Linux ARM64 wheel and say the 1.32.4 Linux wheels need glibc 2.34 or later (1.29.0's needed 2.17). There is no sdist, so .[health] no longer installs on RHEL 8, Ubuntu 20.04, Debian 11 or Amazon Linux 2. CONTRIBUTING also mentions --json --html.

Comparison on main (macOS ARM64)

1.29.0 1.32.4
Health score 77 87
Duplication 65 (10 groups) 95 (5 groups)
Coupling 85 95
Architecture 84 91
Dependencies 70 (depth 11) 70 (depth 13)
Project root checkout checkout
Unresolved imports not reported 0

Both versions resolve the checkout as the root. The score rise comes from the new version's scoring, not from any code change, so the next weekly run is a new baseline.

I ran the updated workflow by hand on this branch from my fork (run). Every step succeeded, the sanity step printed modules=62 files=62 dependencies=198 root=/home/runner/work/dataretrieval-python/dataretrieval-python with no warning, and the artifact contains both the JSON and the HTML report. Locally, the check printed both warnings for a report edited to a wrong root and 15 modules, and named the key for a report with project_root removed. Pre-commit passes.

For the issue author

The project-root comment was written defensively when the workflow was added. In the weekly runs I checked (08-24, 09-07 and 10-12), the reported root was always the checkout and the warning never fired, so I have no run where it went wrong.

Follow-ups, not in this PR

  • No step compares the report's clone groups with .pyscn-known-clones.json, which is how the file drifted.
  • The NWDC _validate_county/_validate_huc pair is private, so the file's reason for accepting clones does not apply. One helper could replace both, and their messages lack a remedy.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HBt3Ee7eneKtdKQWq2T3YK

thodson-usgs and others added 2 commits October 13, 2026 07:48
- Pin pyscn==1.32.4 (was 1.29.0) in the [health] extra.
- One pyscn run now writes both the JSON and the HTML report
  (--json --html), instead of analyzing the package twice.
- The sanity step reads the 1.30.0+ snake_case keys
  (system.summary.project_root, total_dependencies, total_modules) and
  also reports resolved_imports and unresolved_imports, warning when any
  import is unresolved as well as when the root is not the checkout.
- Regenerate .pyscn-known-clones.json with 1.32.4. Its default clone
  grouping (complete_linkage, was connected) and min_lines (8, was 10)
  changed, so the accepted groups differ.
- Note the new Linux ARM64 wheel.

The scores are not comparable across the bump: on main, 1.29.0 reports
77/100 and 1.32.4 reports 87/100 for the same tree, with the same root
and no unresolved imports.

Closes DOI-USGS#415.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HBt3Ee7eneKtdKQWq2T3YK
Review fixes for the pyscn 1.32.4 bump.

- The sanity step no longer relies on unresolved_imports: under a wrong
  root pyscn counts the package's own imports as external, so the count
  stays 0 (checked by analyzing a copy under another root: 15 modules,
  5 dependencies, 0 unresolved). It now warns separately when the root
  is not the checkout and when pyscn analyzed fewer than 90% of the
  package's .py files.
- Missing report keys are named in the summary instead of raising a
  KeyError to stderr, so a future key rename shows up rather than
  silently dropping the sanity line.
- The 1.32.4 Linux wheels need glibc 2.34 (1.29.0's needed 2.17), and
  there is no sdist; pyproject.toml and CONTRIBUTING.md say so.
- .pyscn-known-clones.json: the 2026-08-09 docstring measurements are
  marked as pyscn 1.29.0 only, since 1.32.4 skips docstrings; the Water
  Data rationales no longer cite docstrings; the marginal type-4 pair
  (0.672) gets its own rationale; default_thresholds records group_mode,
  group_threshold, skip_docstrings, and clone_types; and the
  sub-threshold note says it was a 1.29.0 scan.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HBt3Ee7eneKtdKQWq2T3YK
@thodson-usgs
thodson-usgs marked this pull request as ready for review October 13, 2026 13:07
@thodson-usgs
thodson-usgs merged commit 3bc5e0e into DOI-USGS:main Oct 13, 2026
11 checks passed
@thodson-usgs
thodson-usgs deleted the chore/bump-pyscn branch October 13, 2026 13:08
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.

project-root inference in your code-health workflow

1 participant