Skip to content

Commit 4cdce76

Browse files
Cesar-Cardosofacebook-github-bot
authored andcommitted
Fix pyre errors in experiment.py (facebook#4179)
Summary: Fix remaining Pyre errors in experiment.py Reviewed By: mpolson64, lena-kashtelyan Differential Revision: D80579073
1 parent 3539e98 commit 4cdce76

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

ax/core/experiment.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ def __init__(
126126
# pyre-fixme[13]: Attribute `_search_space` is never initialized.
127127
self._search_space: SearchSpace
128128
self._status_quo: Arm | None = None
129-
# pyre-fixme[13]: Attribute `_is_test` is never initialized.
130-
self._is_test: bool
129+
self._is_test: bool = False
131130

132131
self._name = name
133132
self.description = description
@@ -136,14 +135,12 @@ def __init__(
136135

137136
self._data_by_trial: dict[int, OrderedDict[int, Data]] = {}
138137
self._experiment_type: str | None = experiment_type
139-
# pyre-fixme[4]: Attribute must be annotated.
140-
self._optimization_config = None
138+
self._optimization_config: OptimizationConfig | None = None
141139
self._tracking_metrics: dict[str, Metric] = {}
142140
self._time_created: datetime = datetime.now()
143141
self._trials: dict[int, BaseTrial] = {}
144142
self._properties: dict[str, Any] = properties or {}
145-
# pyre-fixme[4]: Attribute must be annotated.
146-
self._default_data_type = default_data_type or DataType.DATA
143+
self._default_data_type: DataType = default_data_type or DataType.DATA
147144
# Used to keep track of whether any trials on the experiment
148145
# specify a TTL. Since trials need to be checked for their TTL's
149146
# expiration often, having this attribute helps avoid unnecessary
@@ -402,20 +399,20 @@ def status_quo(self, status_quo: Arm | None) -> None:
402399
# If old status_quo not present in any trials,
403400
# remove from _arms_by_signature
404401
if self._status_quo is not None:
402+
old_status_quo_name = self._status_quo.name
403+
old_status_quo_signature = self._status_quo.signature
405404
logger.warning(
406405
"Experiment's status_quo is updated. "
407406
"Generally the status_quo should not be changed after being set."
408407
)
409408
persist_old_sq = False
410409
for trial in self._trials.values():
411-
# pyre-fixme[16]: `Optional` has no attribute `name`.
412-
if self._status_quo.name in trial.arms_by_name:
410+
if old_status_quo_name in trial.arms_by_name:
413411
persist_old_sq = True
414412
break
415413
if not persist_old_sq:
416-
# pyre-fixme[16]: `Optional` has no attribute `signature`.
417-
self._arms_by_signature.pop(self._status_quo.signature)
418-
self._arms_by_name.pop(self._status_quo.name)
414+
self._arms_by_signature.pop(old_status_quo_signature)
415+
self._arms_by_name.pop(old_status_quo_name)
419416

420417
self._status_quo = status_quo
421418

0 commit comments

Comments
 (0)