Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immutable searchspace #412

Merged
merged 42 commits into from
Nov 22, 2024
Merged

Immutable searchspace #412

merged 42 commits into from
Nov 22, 2024

Conversation

AdrianSosic
Copy link
Collaborator

@AdrianSosic AdrianSosic commented Oct 22, 2024

Fixes #371 by making SubspaceDiscrete stateless.

Current Approach

  • The SubspaceDiscrete.metadata attribute gets deprecated and the responsibility of metadata handling is shifted to Campaign
  • The new mechanism is not yet final (see out of scope below) but designed in a way that allows to implement upcoming changes in a non-breaking manner. In particular:
    • The metadata handling mechanism is redesigned in that the actual metadata representation is completely hidden from the user, i.e. campaign manages the data in form of private attributes. This is to avoid further lock-in into pandas as our search space backend and prepares for future search space improvements by abstracting away the specific implementation details, enabling us to easily offer other backends (polars, databases, etc) in the future.
    • The allow_* flags are not yet migrated to the Campaign class, but the AnnotatedSubspaceDiscrete allows to migrate them in a follow-up PR (Move allow_* flags to Campaign #423) without causing much friction
  • A new user-facing method Campaign.toggle_discrete_candidates now allows convenient and dynamic control over the discrete candidate set, avoiding any fiddling with the backend dataframes and index manipulations. The positive effect can be seen in the much cleaner code parts of the simulation package.

Out of scope / (potentially) coming next

  • Migration of allow_* flags in order to make Campaign the unique place where the concept of metadata exists, i.e. campaigns will be the only stateful objects. A PR taking care of this should follow soon because the get_candidates signature of SubspaceDiscrete currently makes not much sense, as it expects these flags in a context where metadata does not exist.
  • Once the flags are migrated, the AnnotatedSubspaceDiscrete might become obsolete since the Campaign class can then theoretically filter down the space before passing it to the recommender. This however requires an efficient implementation that does not cause unnecessary dataframe copies.
  • Actually turning the state space classes frozen. There a few other things that should be addressed at the same time (i.e. general cleanup of the classes).

@AdrianSosic AdrianSosic self-assigned this Oct 22, 2024
@AdrianSosic AdrianSosic force-pushed the refactor/immutable_searchspace branch 5 times, most recently from 94c018c to c207e77 Compare November 9, 2024 20:34
@AdrianSosic AdrianSosic marked this pull request as ready for review November 9, 2024 21:10
Copy link
Collaborator

@Scienfitz Scienfitz left a comment

Choose a reason for hiding this comment

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

think this looks pretty nice
unlike in many other places I would rate the depreacation of metadata very important and it would be nice if it was functional (ie does what the old thing did plus warning) instead of error. Understand this might not be possible, just saying to perhaps catalyze more thought for this

baybe/simulation/transfer_learning.py Outdated Show resolved Hide resolved
docs/userguide/searchspace.md Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
tests/test_deprecations.py Outdated Show resolved Hide resolved
tests/test_campaign.py Outdated Show resolved Hide resolved
tests/test_campaign.py Outdated Show resolved Hide resolved
baybe/searchspace/discrete.py Show resolved Hide resolved
baybe/searchspace/_annotated.py Show resolved Hide resolved
@AdrianSosic AdrianSosic force-pushed the refactor/immutable_searchspace branch from c3ba88c to d4794b4 Compare November 12, 2024 11:18
Copy link
Collaborator

@AVHopp AVHopp left a comment

Choose a reason for hiding this comment

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

Looks good, just some minot comments

baybe/searchspace/_annotated.py Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
docs/userguide/searchspace.md Show resolved Hide resolved
baybe/campaign.py Show resolved Hide resolved
@AdrianSosic AdrianSosic force-pushed the refactor/immutable_searchspace branch 2 times, most recently from b1f89a0 to a47821e Compare November 14, 2024 07:14
Copy link
Collaborator

@AVHopp AVHopp left a comment

Choose a reason for hiding this comment

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

Thanks for this important PR. Would appreciate if you could include the test dataframes as an example into the docstring of the toggle function but I can also live without that, hence already approve.

baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
@AdrianSosic AdrianSosic force-pushed the refactor/immutable_searchspace branch from 151b049 to 49e4959 Compare November 19, 2024 09:26
@AdrianSosic AdrianSosic force-pushed the refactor/immutable_searchspace branch 2 times, most recently from d278a3f to 27d1c2d Compare November 19, 2024 09:48
Copy link
Collaborator

@AVHopp AVHopp left a comment

Choose a reason for hiding this comment

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

Happy with everything, would only like to hear your reasons for the singledispatchedmethod.

baybe/campaign.py Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/utils/dataframe.py Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Show resolved Hide resolved
baybe/campaign.py Show resolved Hide resolved
docs/userguide/searchspace.md Show resolved Hide resolved
tests/test_campaign.py Outdated Show resolved Hide resolved
baybe/campaign.py Outdated Show resolved Hide resolved
baybe/searchspace/discrete.py Show resolved Hide resolved
@AdrianSosic AdrianSosic force-pushed the refactor/immutable_searchspace branch from 920123d to ce0982a Compare November 22, 2024 13:52
@AdrianSosic AdrianSosic force-pushed the refactor/immutable_searchspace branch from ce0982a to a0bbc78 Compare November 22, 2024 19:50
@AdrianSosic AdrianSosic merged commit 98cb4ea into main Nov 22, 2024
11 checks passed
@AdrianSosic AdrianSosic deleted the refactor/immutable_searchspace branch November 22, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Immutable search spaces
3 participants