Skip to content

Ship 0.15.2 patches to main - #962

Open
AdrianSosic wants to merge 18 commits into
mainfrom
patch/0.15.2
Open

AdrianSosic wants to merge 18 commits into
mainfrom
patch/0.15.2

Conversation

@AdrianSosic

@AdrianSosic AdrianSosic commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

davrens101 and others added 15 commits November 12, 2026 20:32
The fix restores the candidate identities but leaks the opaque `object()`
carrier into `rec.index.name`, which becomes an `object` instance instead of
`material_id`. The added assertions expose this leakage and currently fail.
The opaque `object()` index carrier leaked into `rec.index.name`. Use the
`_df_index` carrier known from `filter_df` instead and restore the candidate
index name in the discrete and hybrid path.
The discrete and hybrid variants shared their setup. Use a single
parametrized test with a common candidate fixture and restrict the
assertions to the candidate identities.
Does not yet exist on the patched version
### Summary

Preserve named candidate identities in discrete and hybrid BoTorch
recommendation result reconstruction.

### Details and comments

When a search space is built from a dataframe with a named sample index
(e.g. `material_id`), discrete recommendation crashes with `KeyError:
'index'` and hybrid discrete/continuous recommendation with `KeyError:
"None of ['index'] are in the columns"`.

Both consumers call `candidates_comp.reset_index()` then look up the
literal column `index`, but pandas uses the original index name instead.
The fix uses a local opaque column label for the index carrier in the
existing reset-index/merge reconstruction, so it cannot collide with
parameter or computational column labels, and reads that same carrier in
both discrete and hybrid paths.

Adds two regressions (discrete + hybrid) using real GP/BoTorch/qLogEI
acquisition with named string indices, asserting configuration-to-sample
identity mapping. Existing FAST_OPTIMIZATION_SETTINGS bound the work.

Verified locally: `pytest -q tests/test_campaign.py` 68 passed including
both new regressions; ruff/format/flake8/pydoclint pass on changed
files.

AI-assisted implementation; no human-review claim beyond this record.
`Campaign.parameters` also contains continuous parameters, so relying on the
surrounding `DISCRETE` guard made the block fragile. The discrete accessor is
also an existing property, making the comprehension redundant.
Both tests only differed in the search space. The unified case asserts all
columns and the index name instead of a single column.
### Summary

Preserve candidate identities when excluding pending experiments.

### Details and comments

`Campaign.recommend` merged discrete candidate rows with pending
experiments, producing a fresh `RangeIndex` and potentially multiple
rows per candidate. That indexed merge result was OR-ed with metadata
carrying the original candidate indices and applied as a positional
filter, so supported `SearchSpace.from_dataframe` inputs with sample IDs
could return a pending experiment again (even with
`allow_recommending_pending_experiments=False`) or raise
`NotEnoughPointsLeftError` although valid candidates remained.

The fix replaces the merge-indicator Series with exact joint-row
membership over consistently ordered discrete parameter columns,
yielding one positional boolean per candidate regardless of sample index
or duplicate pending rows. Existing measured/recommended/excluded
metadata restrictions are combined unchanged; off-grid/tolerance
behavior and rejection of empty pending dataframes are untouched.

Adds regressions covering string/named/reordered numeric indices,
duplicate pending rows, the allow-pending flag, nonmatching pending data
and mixed categorical/numeric row matching.

Verified locally: `pytest -q tests/test_campaign.py` 72 passed;
ruff/format/flake8/pydoclint pass on changed files.

AI-assisted implementation; no human-review claim beyond this record.
@AdrianSosic AdrianSosic self-assigned this Nov 13, 2026
@AdrianSosic AdrianSosic added the bug Something isn't working label Nov 13, 2026
@AdrianSosic
AdrianSosic marked this pull request as ready for review November 13, 2026 10:17
Copilot AI balanced review requested due to automatic review settings November 13, 2026 10:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The hybrid index regression bypasses the required fast-test recommender configuration, causing unnecessary optimization work.

1 open issue
What changed in this PR

Brings the 0.15.2 recommendation patches from #958 and #959 to main, addressing candidate-index handling in BayBE’s recommendation pipeline.

Changes:

  • Preserve named candidate indices during discrete and hybrid BoTorch result reconstruction.
  • Exclude pending discrete configurations without misaligning custom indices or duplicating candidates.
  • Add regression coverage, document the release, and enable CI for patch branches.
File Description
tests/​test_campaign.py Adds pending-experiment filtering and named-index regressions.
CHANGELOG.md Documents the two 0.15.2 fixes.
baybe/​recommenders/​pure/​bayesian/​botorch/​hybrid.py Preserves named indices during hybrid result reconstruction.
baybe/​recommenders/​pure/​bayesian/​botorch/​discrete.py Preserves named indices during discrete result reconstruction.
baybe/​campaign.py Filters pending experiments using exact joint-row membership.
.github/​workflows/​ci.yml Enables CI for patch/** branches.

Review effort: Balanced

Comment thread tests/test_campaign.py Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants