Skip to content

Commit 6d78f18

Browse files
Richa Gadgilfacebook-github-bot
authored andcommitted
Fix ValueError in FillMissingParameters with empty experiment data
Summary: `FillMissingParameters.transform_experiment_data` crashes with `ValueError: Columns must be same length as key` when `arm_data` has zero rows (e.g., during initial Sobol trial generation before any trials have completed). This happens because `DataFrame.apply(func, axis=1)` on an empty DataFrame returns an empty DataFrame rather than an empty Series. Assigning that DataFrame to a single column then fails. Replace `arm_data.apply(...)` with a list comprehension over `arm_data.iterrows()`, which correctly produces an empty list for empty DataFrames. Failing run: https://www.internalfb.com/mlhub/flow/1044918711/overview Differential Revision: D95266027
1 parent 1cd0b89 commit 6d78f18

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

ax/adapter/transforms/fill_missing_parameters.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ def transform_experiment_data(
101101
if c != "metadata" and c not in self._derived_parameters
102102
]
103103
for p_name, p in self._derived_parameters.items():
104-
arm_data[p_name] = arm_data.apply(
105-
lambda row, p=p: p.compute({col: row[col] for col in tunable_cols}),
106-
axis=1,
107-
)
104+
arm_data[p_name] = [
105+
p.compute({col: row[col] for col in tunable_cols})
106+
for _, row in arm_data.iterrows()
107+
]
108108
return ExperimentData(
109109
arm_data=arm_data,
110110
observation_data=experiment_data.observation_data,

0 commit comments

Comments
 (0)