Skip to content

Conversation

@esantorella
Copy link
Contributor

Summary:
This diff gets rid of Experiment._data_by_trial: dict[int, OrderedDict[int, Data]] and replaces it with Experiment.data: Data

Changes:

  • Experiment has a data attribute and does not have a _data_by_trial attribute. I did not hide this attribute since I think it is fine to update Experiment.data
    ** Attaching data now is simpler
  • Added property data.trial_indices since there were many checks for _data_by_trial.keys()
  • Serialization changes: Basically, everything eventually still becomes _data_by_trial the last step in serialization or the first step in deserialization. The db is not affected.
    ** Note that add_experiment_id gets some more substantive changes since there is now one Data rather than 1+ Data for each trial.

Migration off _data_by_trial:
* To keep tests passing and relevant, I added a property _data_by_trial.
* But a subsequent diff should take this out and update the tests to reference Data instead

  • I initially added _data_by_trial as a property. This is quite dangerous since while experiment._data_by_trial cannot be set, experiment._data_by_trial[0][0] = ... is allowed and could mislead people into thinking they are updating the data on the trial. _data_by_trial ought to be removed.

Differential Revision: D86452716

@meta-cla meta-cla bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Nov 12, 2025
@meta-codesync
Copy link

meta-codesync bot commented Nov 12, 2025

@esantorella has exported this pull request. If you are a Meta employee, you can view the originating Diff in D86452716.

esantorella added a commit to esantorella/Ax that referenced this pull request Dec 18, 2025
Summary:

This diff gets rid of `Experiment._data_by_trial: dict[int, OrderedDict[int, Data]]` and replaces it with `Experiment.data: Data`

**Changes**:
* `Experiment` has a `data` attribute and does not have a `_data_by_trial` attribute. I did not hide this attribute since I think it is fine to update `Experiment.data`
** Attaching data now is simpler
* Added property `data.trial_indices` since there were many checks for `_data_by_trial.keys()`
* Serialization changes: Basically, everything eventually still becomes _data_by_trial the last step in serialization or the first step in deserialization. The db is not affected.
** Note that `add_experiment_id` gets some more substantive changes since there is now one `Data` rather than 1+ `Data` for each trial.

**Migration off _data_by_trial**:
~~* To keep tests passing and relevant, I added a property `_data_by_trial`.~~
~~* But a subsequent diff should take this out and update the tests to reference `Data` instead~~
* I initially added `_data_by_trial` as a property. This is quite dangerous since while `experiment._data_by_trial` cannot be set, `experiment._data_by_trial[0][0] = ...` is allowed and could mislead people into thinking they are updating the data on the trial. `_data_by_trial` ought to be removed.

Differential Revision: D86452716
esantorella added a commit to esantorella/Ax that referenced this pull request Dec 26, 2025
Summary:
Pull Request resolved: facebook#4529

This diff gets rid of `Experiment._data_by_trial: dict[int, OrderedDict[int, Data]]` and replaces it with `Experiment.data: Data`

**Changes**:
* `Experiment` has a `data` attribute and does not have a `_data_by_trial` attribute. I did not hide this attribute since I think it is fine to update `Experiment.data`
** Attaching data now is simpler
* Added property `data.trial_indices` since there were many checks for `_data_by_trial.keys()`
* Serialization changes: Basically, everything eventually still becomes _data_by_trial the last step in serialization or the first step in deserialization. The db is not affected.
** Note that `add_experiment_id` gets some more substantive changes since there is now one `Data` rather than 1+ `Data` for each trial.

**Migration off _data_by_trial**:
~~* To keep tests passing and relevant, I added a property `_data_by_trial`.~~
~~* But a subsequent diff should take this out and update the tests to reference `Data` instead~~
* I initially added `_data_by_trial` as a property. This is quite dangerous since while `experiment._data_by_trial` cannot be set, `experiment._data_by_trial[0][0] = ...` is allowed and could mislead people into thinking they are updating the data on the trial. `_data_by_trial` ought to be removed.

Differential Revision: D86452716
esantorella added a commit to esantorella/Ax that referenced this pull request Dec 26, 2025
Summary:
Pull Request resolved: facebook#4529

This diff gets rid of `Experiment._data_by_trial: dict[int, OrderedDict[int, Data]]` and replaces it with `Experiment.data: Data`

**Changes**:
* `Experiment` has a `data` attribute and does not have a `_data_by_trial` attribute. I did not hide this attribute since I think it is fine to update `Experiment.data`
** Attaching data now is simpler
* Added property `data.trial_indices` since there were many checks for `_data_by_trial.keys()`
* Serialization changes: Basically, everything eventually still becomes _data_by_trial the last step in serialization or the first step in deserialization. The db is not affected.
** Note that `add_experiment_id` gets some more substantive changes since there is now one `Data` rather than 1+ `Data` for each trial.

TODO:
* Ensure that serialization and deserialization of empty data works -- this has been a bugbear since empty data is now assumed to be Data. Particularly when there is an existing object in the db

Differential Revision: D86452716
esantorella added a commit to esantorella/Ax that referenced this pull request Jan 2, 2026
Summary:
Pull Request resolved: facebook#4529

This diff gets rid of `Experiment._data_by_trial: dict[int, OrderedDict[int, Data]]` and replaces it with `Experiment.data: Data`

**Changes**:
* `Experiment` has a `data` attribute and does not have a `_data_by_trial` attribute. I did not hide this attribute since I think it is fine to update `Experiment.data`
* Attaching data now is simpler
* Reference `data.trial_indices` instead of `_data_by_trial.keys()`
* Serialization changes: Basically, everything eventually still becomes _data_by_trial the last step in serialization or the first step in deserialization. The db is not affected.

Differential Revision: D86452716

Reviewed By: saitcakmak
esantorella added a commit to esantorella/Ax that referenced this pull request Jan 2, 2026
Summary:
Pull Request resolved: facebook#4529

This diff gets rid of `Experiment._data_by_trial: dict[int, OrderedDict[int, Data]]` and replaces it with `Experiment.data: Data`

**Changes**:
* `Experiment` has a `data` attribute and does not have a `_data_by_trial` attribute. I did not hide this attribute since I think it is fine to update `Experiment.data`
* Attaching data now is simpler
* Reference `data.trial_indices` instead of `_data_by_trial.keys()`
* Serialization changes: Basically, everything eventually still becomes _data_by_trial the last step in serialization or the first step in deserialization. The db is not affected.

Reviewed By: saitcakmak

Differential Revision: D86452716
@codecov-commenter
Copy link

codecov-commenter commented Jan 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.72%. Comparing base (4d8537b) to head (6b8d5a6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4529   +/-   ##
=======================================
  Coverage   96.72%   96.72%           
=======================================
  Files         582      582           
  Lines       60710    60679   -31     
=======================================
- Hits        58721    58692   -29     
+ Misses       1989     1987    -2     

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

esantorella added a commit to esantorella/Ax that referenced this pull request Jan 2, 2026
Summary:

This diff gets rid of `Experiment._data_by_trial: dict[int, OrderedDict[int, Data]]` and replaces it with `Experiment.data: Data`

**Changes**:
* `Experiment` has a `data` attribute and does not have a `_data_by_trial` attribute. I did not hide this attribute since I think it is fine to update `Experiment.data`
* Attaching data now is simpler
* Reference `data.trial_indices` instead of `_data_by_trial.keys()`
* Serialization changes: Basically, everything eventually still becomes _data_by_trial the last step in serialization or the first step in deserialization. The db is not affected.

Reviewed By: saitcakmak

Differential Revision: D86452716
esantorella added a commit to esantorella/Ax that referenced this pull request Jan 2, 2026
Summary:

This diff gets rid of `Experiment._data_by_trial: dict[int, OrderedDict[int, Data]]` and replaces it with `Experiment.data: Data`

**Changes**:
* `Experiment` has a `data` attribute and does not have a `_data_by_trial` attribute. I did not hide this attribute since I think it is fine to update `Experiment.data`
* Attaching data now is simpler
* Reference `data.trial_indices` instead of `_data_by_trial.keys()`
* Serialization changes: Basically, everything eventually still becomes _data_by_trial the last step in serialization or the first step in deserialization. The db is not affected.

Reviewed By: saitcakmak

Differential Revision: D86452716
Summary:

**Context**: This diff exists to split up a more complex change. The next diff, D86452716, will remove `Experiment`'s attribute `_data_by_trial` and give it an attribute `Data`. That is quite a complex change; in addition to the changes on `Experiment`, it requires storage changes and updating many callsites. As a first step, this diff gives `Experiment` a property `data` (which will become an attribute in D86452716) and updates call sites. It should not be landed alone.

**Changes**:
* Gives `Experiment` a property `Data` that is equivalent to `.lookup_data()`
* Updates many call sites to reference `data` rather than `_data_by_trial`

Reviewed By: saitcakmak

Differential Revision: D87004539
Summary:

This diff gets rid of `Experiment._data_by_trial: dict[int, OrderedDict[int, Data]]` and replaces it with `Experiment.data: Data`

**Changes**:
* `Experiment` has a `data` attribute and does not have a `_data_by_trial` attribute. I did not hide this attribute since I think it is fine to update `Experiment.data`
* Attaching data now is simpler
* Reference `data.trial_indices` instead of `_data_by_trial.keys()`
* Serialization changes: Basically, everything eventually still becomes _data_by_trial the last step in serialization or the first step in deserialization. The db is not affected.

Reviewed By: saitcakmak

Differential Revision: D86452716
esantorella added a commit to esantorella/Ax that referenced this pull request Jan 2, 2026
Summary:

This diff gets rid of `Experiment._data_by_trial: dict[int, OrderedDict[int, Data]]` and replaces it with `Experiment.data: Data`

**Changes**:
* `Experiment` has a `data` attribute and does not have a `_data_by_trial` attribute. I did not hide this attribute since I think it is fine to update `Experiment.data`
* Attaching data now is simpler
* Reference `data.trial_indices` instead of `_data_by_trial.keys()`
* Serialization changes: Basically, everything eventually still becomes _data_by_trial the last step in serialization or the first step in deserialization. The db is not affected.

Reviewed By: saitcakmak

Differential Revision: D86452716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants