Skip to content

fix: find segmenters at any depth below Segmenter - #80

Merged
paulmueller merged 2 commits into
DC-analysis:mainfrom
paulmueller-agent:fix-segmenter-subclasses
Nov 23, 2026
Merged

paulmueller merged 2 commits into
DC-analysis:mainfrom
paulmueller-agent:fix-segmenter-subclasses

Conversation

@paulmueller-agent

Copy link
Copy Markdown
Contributor

get_segmenters only collected the subclasses of the direct subclasses of Segmenter (e.g. UNISegmenter → SegmentThresh). A custom segmenter derived from a concrete segmenter was therefore never registered:

class SegmentThreshCustom(SegmentThresh):
    pass

"threshcustom" in segm.get_segmenters()  # False (main), True (this PR)
Segmenter.get_ppkw_from_ppid("threshcustom:t=-6:cle=1^f=1^clo=2")
# main: ValueError: Could not find segmenter 'threshcustom'!

This has been the case since custom segmenters were introduced (0.0.5).

Fix

get_segmenters walks the subclass tree at any depth and registers every class that is not abstract (inspect.isabstract). The abstract intermediate classes (MPOSegmenter, STOSegmenter, UNISegmenter, TorchSegmenterBase) are still excluded, and the set of built-in segmenters is unchanged: thresh, torchmpo, torchsto, torchuni.

get_segmenters keeps its functools.cache, as in the existing tests. A segmenter defined after the first call therefore still requires get_segmenters.cache_clear().

Tests

  • New test_ppid_decoding_subclass_of_segmenter_subclass: registration, the PPID round trip, and that abstract bases are excluded. It fails on main and passes here.
  • The segmenter tests pass (test_segm_thresh cannot run locally because of a missing HDF5 plugin directory; this happens on main too). All 71 pipeline tests pass, run one per process locally.
  • flake8 is clean, and ruff shows no new errors.

🤖 Generated with Claude Code

`get_segmenters` only looked at the subclasses of the direct
subclasses of `Segmenter` (e.g. `UNISegmenter` -> `SegmentThresh`).
A custom segmenter derived from a concrete segmenter (e.g. from
`SegmentThresh`) was therefore not found, and its pipeline identifier
could not be resolved. All non-abstract subclasses at any depth are
now registered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.14%. Comparing base (bc11997) to head (86f4732).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #80      +/-   ##
==========================================
- Coverage   88.18%   88.14%   -0.04%     
==========================================
  Files          63       63              
  Lines        4519     4522       +3     
==========================================
+ Hits         3985     3986       +1     
- Misses        534      536       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paulmueller
paulmueller merged commit 3e172b6 into DC-analysis:main Nov 23, 2026
6 checks passed
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