Skip to content

Conversation

Copy link

Copilot AI commented Oct 14, 2025

Summary

Fixed bug where requesting more recommendations than available candidates incorrectly raised NotEnoughPointsLeftError when allow_recommending_already_recommended=True.

Changes

Rebased branch onto main - Clean single commit on top of main
Fixed pre-commit linting issues - All formatting checks pass
Removed incorrect guard clause in PureRecommender._recommend_with_discrete_parts()
Updated all recommenders to handle batch_size > candidates with replacement:

  • RandomRecommender
  • FPSRecommender
  • Clustering recommenders
  • BotorchRecommender
    Added test case in test_campaign.py

Fixes #369

Original prompt

This section details on the original issue you should resolve

<issue_title>Bug when batch size exceeds number of candidates</issue_title>
<issue_description>When setting allow_repeated_recommendations=True it is perfectly valid to request more recommendations than there are candidates in the search space. However, the code currently throws an incorrect exception due to a badly designed guard clause. A TODO note is already in the code for a while but we finally need to take care of it 🙈

from baybe.parameters import NumericalDiscreteParameter
from baybe.recommenders import RandomRecommender

searchspace = NumericalDiscreteParameter("p", [0, 1]).to_searchspace()
recommender = RandomRecommender(allow_repeated_recommendations=True)
recommender.recommend(5, searchspace)
baybe.exceptions.NotEnoughPointsLeftError: Using the current settings, there are fewer than 5 possible data points left to recommend. This can be either because all data points have been measured at some point (while 'allow_repeated_recommendations' or 'allow_recommending_already_measured' being False) or because all data points are marked as 'dont_recommend'.

</issue_description>

Comments on the Issue (you are @copilot in this section)

@Scienfitz I think two types of fixes are required for this - [ ] make the candidate creation respect that and not throw the `NotEnoughCandidatesError` - [ ] all recommenders need to respect the situation where more points are requested than are available

Fixes #369


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@CLAassistant
Copy link

CLAassistant commented Oct 14, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
3 out of 4 committers have signed the CLA.

✅ AdrianSosic
✅ Hrovatin
✅ Scienfitz
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix bug when batch size exceeds number of candidates Fix bug when batch size exceeds number of candidates with allow_recommending_already_recommended=True Oct 14, 2025
Copilot AI requested a review from AVHopp October 14, 2025 11:56
Copilot finished work on behalf of AVHopp October 14, 2025 11:56
@AVHopp
Copy link
Collaborator

AVHopp commented Oct 24, 2025

@copilot The pre-commit.ci checks are failing. Fix this. Also, make sure that the branch is rebased onto main.

Copy link
Author

Copilot AI commented Oct 24, 2025

@copilot The pre-commit.ci checks are failing. Fix this. Also, make sure that the branch is rebased onto main.

Fixed both issues:

  1. Pre-commit checks: Fixed all linting issues (line length, formatting) identified by ruff and pyupgrade
  2. Rebase onto main: Branch has been rebased onto main with a clean commit history

The local branch is now properly based on main (commit 70a99c7) with a single clean commit containing all the changes. However, there's a technical limitation preventing the force push - the remote branch currently has an incorrect history with 32 commits that aren't properly based on main.

Manual intervention needed: The remote branch copilot/fix-batch-size-exception needs to be force-pushed to match the local clean state. The changes are ready and all checks pass locally (commit de8fde2).

Copilot finished work on behalf of AVHopp October 24, 2025 13:30
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.

Bug when batch size exceeds number of candidates

6 participants