Skip to content

Commit 427bcdd

Browse files
committed
Fix ax_trial_id
1 parent 4bf8c28 commit 427bcdd

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

optimas/core/trial.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def __init__(
6868
)
6969
self._ignored = False
7070
self._ignored_reason = None
71-
7271
# Add custom parameters as trial attributes.
7372
for param in self._custom_parameters:
7473
setattr(self, param.name, None)
@@ -93,6 +92,10 @@ def to_dict(self) -> Dict:
9392
"_ignored_reason": self._ignored_reason,
9493
"_status": self._status,
9594
}
95+
96+
if hasattr(self, "_ax_trial_id"):
97+
trial_dict["ax_trial_id"] = self._ax_trial_id
98+
9699
return trial_dict
97100

98101
@classmethod
@@ -139,6 +142,8 @@ def from_dict(
139142
)
140143
if "_id" in trial_dict:
141144
trial._index = trial_dict["_id"]
145+
if "ax_trial_id" in trial_dict:
146+
trial._ax_trial_id = trial_dict["ax_trial_id"]
142147
if "_ignored" in trial_dict:
143148
trial._ignored = trial_dict["_ignored"]
144149
if "_ignored_reason" in trial_dict:

optimas/generators/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ def ask_trials(self, n_trials: int) -> List[Trial]:
216216
analyzed_parameters=self._analyzed_parameters,
217217
custom_parameters=self._custom_trial_parameters,
218218
)
219+
if 'ax_trial_id' in point:
220+
trial.ax_trial_id = point['ax_trial_id']
219221
gen_trials.append(trial)
220222
# Keep only trials that have been given data.
221223
for trial in gen_trials:

0 commit comments

Comments
 (0)