Skip to content

Commit

Permalink
Typechecking fix re: experiment data types
Browse files Browse the repository at this point in the history
Differential Revision: D69313263
  • Loading branch information
lena-kashtelyan authored and facebook-github-bot committed Feb 7, 2025
1 parent c469174 commit 6b8287b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ax/core/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,9 +1120,7 @@ def default_data_type(self) -> DataType:
return self._default_data_type

@property
# pyre-fixme[24]: Generic type `type` expects 1 type parameter, use
# `typing.Type` to avoid runtime subscripting errors.
def default_data_constructor(self) -> type:
def default_data_constructor(self) -> type[Data]:
return DATA_TYPE_LOOKUP[self.default_data_type]

def new_trial(
Expand Down Expand Up @@ -1412,15 +1410,16 @@ def warm_start_from_old_experiment(
inplace=True,
)
# Attach updated data to new trial on experiment.
data_constructor = old_experiment.default_data_constructor
old_data = (
old_experiment.default_data_constructor(
cast(type[MapData], data_constructor)(
df=new_df,
map_key_infos=assert_is_instance(
old_experiment.lookup_data(), MapData
).map_key_infos,
)
if old_experiment.default_data_type == DataType.MAP_DATA
else old_experiment.default_data_constructor(df=new_df)
if data_constructor == MapData
else data_constructor(df=new_df)
)
self.attach_data(data=old_data)
if trial.status == TrialStatus.ABANDONED:
Expand Down

0 comments on commit 6b8287b

Please sign in to comment.