Skip to content

feat: support multiple DR parameter sets in a single prepare run#48

Merged
tsenoner merged 4 commits into
mainfrom
feat/multi-dr-params
Apr 27, 2026
Merged

feat: support multiple DR parameter sets in a single prepare run#48
tsenoner merged 4 commits into
mainfrom
feat/multi-dr-params

Conversation

@tsenoner
Copy link
Copy Markdown
Owner

Summary

Closes #46.

  • Add inline per-method parameter overrides to -m flag: -m "umap2:n_neighbors=50;min_dist=0.1"
  • Commas separate methods, semicolons separate params — fully backward compatible
  • -m is now repeatable: -m "umap2:n_neighbors=15" -m "umap2:n_neighbors=50" -m pca2
  • Smart projection naming: when the same method+dims appears multiple times, appends abbreviated params (e.g., ProtT5 — UMAP 2 (n=50))
  • Per-method cache keys so each parameter set gets its own cached projection
  • Both prepare and project commands support the new syntax

New types

  • MethodSpec frozen dataclass: (method, dims, overrides) — replaces bare strings
  • parse_methods_arg(): parses repeatable -m with comma+colon+semicolon syntax

Files changed

  • pipeline.pyMethodSpec, parse_method_spec(), parse_methods_arg(), _run_reductions(), cache helpers
  • embedding_set.pyformat_param_suffix(), extended format_projection_name()
  • common_options.pyOpt_Methods changed from str to list[str] | None
  • prepare.py, project.py — wired up new parsing
  • docs/cli.md, CLAUDE.md, notebook — documentation updated
  • test_pipeline_utils.py — 29 new tests (41 → 70)

Test plan

  • All 483 tests pass (uv run pytest tests/ -m "not slow")
  • Ruff lint clean
  • Backward compat: -m pca2,umap2 works unchanged
  • New feature: -m "umap2:n_neighbors=15" -m "umap2:n_neighbors=50" -m pca2 produces 3 projections with correct names
  • Bundle verified: ProtT5 — UMAP 2 (n=15), ProtT5 — UMAP 2 (n=50), ProtT5 — PCA 2
  • End-to-end: open bundle at protspace.app and verify projection dropdown

🤖 Generated with Claude Code

tsenoner and others added 4 commits April 18, 2026 16:28
Allow inline per-method parameter overrides in the -m flag using colon
syntax with semicolon-separated params. This enables comparing the same
DR method with different parameters in a single run without re-running
the full pipeline.

Example: -m "umap2:n_neighbors=15" -m "umap2:n_neighbors=50" -m pca2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Centralize the param-suffix rule used by ReductionPipeline._run_reductions
into a single helper so cli/project.py can share it (follow-up commit).

Includes a regression test for the mixed plain+override case
(`-m umap2 -m umap2:n_neighbors=50`) which currently emits "ProtT5 — UMAP 2"
and "ProtT5 — UMAP 2 (n=50)".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add _run_with_overridden_config(base, effective_params, method, dims, data)
  to pipeline.py to centralize the save/restore pattern for BaseProcessor.config.
  A leaked `precomputed` flag (or any temporary key) can no longer survive
  across reduction calls.
- Update ReductionPipeline._run_reductions and cli/project.py to use both
  the new helper and disambiguation_suffix. cli/project.py previously set
  base.config without restoring it; this is now handled in one place.
- Hoist the lazy in-test imports added in the previous commit to the top-level
  import block in tests/test_pipeline_utils.py.

Addresses PR #48 review feedback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The precomputed-MDS branch in _run_reductions was the last call site
still mutating self.base.config in place (set precomputed=True, then
pop() after). Migrate it to _run_with_overridden_config so:

- The save/restore pattern is consistent across all reduction call sites.
- A precomputed flag can no longer survive in base.config if
  process_reduction raises mid-call.

Regression tests cover both the happy path (flag is set during
reduction, cleared after) and the exception path (flag is cleared
even when reduction raises).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tsenoner tsenoner merged commit b0b73f5 into main Apr 27, 2026
4 checks passed
@tsenoner tsenoner deleted the feat/multi-dr-params branch April 27, 2026 12:16
martinpycha pushed a commit to d0rr4/PP1 that referenced this pull request May 20, 2026
- Add _run_with_overridden_config(base, effective_params, method, dims, data)
  to pipeline.py to centralize the save/restore pattern for BaseProcessor.config.
  A leaked `precomputed` flag (or any temporary key) can no longer survive
  across reduction calls.
- Update ReductionPipeline._run_reductions and cli/project.py to use both
  the new helper and disambiguation_suffix. cli/project.py previously set
  base.config without restoring it; this is now handled in one place.
- Hoist the lazy in-test imports added in the previous commit to the top-level
  import block in tests/test_pipeline_utils.py.

Addresses PR tsenoner#48 review feedback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
martinpycha pushed a commit to d0rr4/PP1 that referenced this pull request May 20, 2026
feat: support multiple DR parameter sets in a single prepare run
martinpycha pushed a commit to d0rr4/PP1 that referenced this pull request May 20, 2026
Follow-up to PR tsenoner#48 review feedback.

- docs/cli.md: rewrite -m flag description to spell out the
  comma-vs-semicolon rule explicitly, add an "Overridable parameters"
  subsection listing the 11 valid override keys with their abbreviations
  and types, and extend "Projection Naming" with an example of the
  parameter-suffix disambiguation behavior.
- notebooks/ProtSpace_Preparation.ipynb: insert an informational markdown
  cell pointing power users at the CLI for parameter sweeps, since the
  toggle UI runs each method only once.

No code or behavior changes; release-bot will not bump the version.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

Support multiple DR parameter sets in a single prepare run

1 participant