@@ -555,7 +555,7 @@ def get_metrics(self, metric_names: list[str] | None) -> list[Metric]:
555555 def fetch_data_results (
556556 self ,
557557 metrics : list [Metric ] | None = None ,
558- combine_with_last_data : bool = False ,
558+ combine_with_last_data : bool | None = None ,
559559 overwrite_existing_data : bool = False ,
560560 ** kwargs : Any ,
561561 ) -> dict [int , dict [str , MetricFetchResult ]]:
@@ -593,7 +593,7 @@ def fetch_trials_data_results(
593593 self ,
594594 trial_indices : Iterable [int ],
595595 metrics : list [Metric ] | None = None ,
596- combine_with_last_data : bool = False ,
596+ combine_with_last_data : bool | None = None ,
597597 overwrite_existing_data : bool = False ,
598598 ** kwargs : Any ,
599599 ) -> dict [int , dict [str , MetricFetchResult ]]:
@@ -629,7 +629,7 @@ def fetch_data(
629629 self ,
630630 trial_indices : Iterable [int ] | None = None ,
631631 metrics : list [Metric ] | None = None ,
632- combine_with_last_data : bool = False ,
632+ combine_with_last_data : bool | None = None ,
633633 overwrite_existing_data : bool = False ,
634634 ** kwargs : Any ,
635635 ) -> Data :
@@ -676,7 +676,7 @@ def _lookup_or_fetch_trials_results(
676676 self ,
677677 trials : list [BaseTrial ],
678678 metrics : Iterable [Metric ] | None = None ,
679- combine_with_last_data : bool = False ,
679+ combine_with_last_data : bool | None = None ,
680680 overwrite_existing_data : bool = False ,
681681 ** kwargs : Any ,
682682 ) -> dict [int , dict [str , MetricFetchResult ]]:
@@ -755,23 +755,27 @@ def _fetch_trial_data(
755755 def attach_data (
756756 self ,
757757 data : Data ,
758- combine_with_last_data : bool = False ,
758+ # TODO[bbeckerman]: Deprecate this argument.
759+ combine_with_last_data : bool | None = None ,
759760 overwrite_existing_data : bool = False ,
760761 ) -> int :
761762 """Attach data to experiment. Stores data in `experiment._data_by_trial`,
762763 to be looked up via `experiment.lookup_data_for_trial`.
763764
764765 Args:
765766 data: Data object to store.
766- combine_with_last_data: By default, when attaching data, it's identified
767+ combine_with_last_data [DEPRECATED]: This argument will be removed in Ax
768+ 1.3.0. Please leave this as ``None``, in which case it will be assigned
769+ as ``not overwrite_existing_data``.
770+ By default, when attaching data, it's identified
767771 by its timestamp, and `experiment.lookup_data_for_trial` returns
768772 data by most recent timestamp. Sometimes, however, we want to combine
769773 the data from multiple calls to `attach_data` into one dataframe.
770774 This might be because:
771775 - We attached data for some metrics at one point and data for
772776 the rest of the metrics later on.
773777 - We attached data for some fidelity at one point and data for
774- another fidelity later one .
778+ another fidelity later on .
775779 To achieve that goal, set `combine_with_last_data` to `True`.
776780 In this case, we will take the most recent previously attached
777781 data, append the newly attached data to it, attach a new
@@ -785,10 +789,34 @@ def attach_data(
785789 the incoming data contains all the information we need for a given
786790 trial, we can replace the existing data for that trial, thereby
787791 reducing the amount we need to store in the database.
792+ If set to False, we will combine the data in the present call with that
793+ from prior calls to `attach_data`, into one dataframe. Reasons to do
794+ this may include:
795+ - We attached data for some metrics at one point and data for
796+ the rest of the metrics later on.
797+ - We attached data for some fidelity at one point and data for
798+ another fidelity later on.
799+ In this case, we will take the most recent previously attached
800+ data, append the newly attached data to it, and attach a new
801+ Data object with the merged result and delete the old one.
802+ Afterwards, calls to `lookup_data_for_trial` will return this
803+ new combined data object. This operation will also validate that the
804+ newly added data does not contain observations for metrics that
805+ already have observations at the same fidelity in the most recent data.
806+
788807
789808 Returns:
790809 Timestamp of storage in millis.
791810 """
811+ if combine_with_last_data is None :
812+ combine_with_last_data = not overwrite_existing_data
813+ else :
814+ # logger.warning(
815+ raise DeprecationWarning (
816+ "The `combine_with_last_data` argument is deprecated and will be "
817+ "removed soon. Please leave this as None, in which case it will be "
818+ "assigned as `not overwrite_existing_data`."
819+ )
792820 if combine_with_last_data and overwrite_existing_data :
793821 raise UnsupportedError (
794822 "Cannot set both combine_with_last_data=True and "
@@ -921,7 +949,7 @@ def _get_last_data_without_similar_rows(
921949 def attach_fetch_results (
922950 self ,
923951 results : Mapping [int , Mapping [str , MetricFetchResult ]],
924- combine_with_last_data : bool = False ,
952+ combine_with_last_data : bool | None = None ,
925953 overwrite_existing_data : bool = False ,
926954 ) -> int | None :
927955 """
0 commit comments