Skip to content

Commit fbeaec3

Browse files
committed
Use getter/setter
1 parent c105ef2 commit fbeaec3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

optimas/core/trial.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def to_dict(self) -> Dict:
9494
}
9595

9696
if hasattr(self, "_ax_trial_id"):
97-
trial_dict["ax_trial_id"] = self._ax_trial_id
97+
trial_dict["ax_trial_id"] = self.ax_trial_id
9898

9999
return trial_dict
100100

@@ -123,6 +123,7 @@ def from_dict(
123123
Additional parameters needed to identify or carry out the trial, and
124124
which will be included in the optimization history.
125125
"""
126+
126127
# Prepare values of the input parameters
127128
parameter_values = [trial_dict[var.name] for var in varying_parameters]
128129
# Prepare evaluations
@@ -152,6 +153,7 @@ def from_dict(
152153
trial._status = trial_dict["_status"]
153154
for custom_param in custom_parameters:
154155
setattr(trial, custom_param.name, trial_dict[custom_param.name])
156+
155157
return trial
156158

157159
@property
@@ -202,6 +204,15 @@ def index(self) -> int:
202204
def index(self, value):
203205
self._index = value
204206

207+
@property
208+
def ax_trial_id(self) -> int:
209+
"""Get the index of the trial."""
210+
return self._ax_trial_id
211+
212+
@ax_trial_id.setter
213+
def ax_trial_id(self, value):
214+
self._ax_trial_id = value
215+
205216
@property
206217
def ignored(self) -> bool:
207218
"""Get whether the trial is ignored by the generator."""

optimas/generators/ax/service/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def ingest(self, results: List[dict]) -> None:
168168
custom_parameters=self._custom_trial_parameters,
169169
)
170170
try:
171-
trial_id = trial.ax_trial_id
171+
trial_id = trial._ax_trial_id
172172
ax_trial = self._ax_client.get_trial(trial_id)
173173
except AttributeError:
174174
params = {}

0 commit comments

Comments
 (0)