Ax icon indicating copy to clipboard operation
Ax copied to clipboard

Replace `_data_by_trial` with `Data` on Experiment

Open esantorella opened this issue 1 month ago • 1 comments

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 avatar Nov 12 '25 20:11 esantorella

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

meta-codesync[bot] avatar Nov 12 '25 20:11 meta-codesync[bot]