Skip to content

Commit ad057da

Browse files
saitcakmakfacebook-github-bot
authored andcommitted
Fix lint errors in scheduler (#1140)
Summary: Pull Request resolved: #1140 Title Reviewed By: bernardbeckerman Differential Revision: D39529560 fbshipit-source-id: bea33268a262d0c3c894a41bdd691890fdf7c47f
1 parent 01c7391 commit ad057da

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

ax/service/scheduler.py

+20-12
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@
7878
OPTIMIZATION_COMPLETION_MSG = """Optimization completed with total of {num_trials}
7979
trials attached to the underlying Ax experiment '{experiment_name}'.
8080
"""
81+
FAILURE_EXCEEDED_MSG = (
82+
"Failure rate exceeds the tolerated trial failure rate of {f_rate} (at least "
83+
"{n_failed} out of first {n_ran} trials failed). Checks are triggered both at "
84+
"the end of a optimization and if at least {min_failed} trials have failed."
85+
)
8186

8287

8388
# Wait time b/w reports will not exceed 15 mins.
@@ -95,7 +100,9 @@ class SchedulerInternalError(AxError):
95100

96101

97102
class FailureRateExceededError(AxError):
98-
"""Error that indicates the optimization was aborted due to excessive failure rate."""
103+
"""Error that indicates the optimization was aborted due to excessive
104+
failure rate.
105+
"""
99106

100107
pass
101108

@@ -156,8 +163,8 @@ class Scheduler(WithDBSettingsBase, BestPointMixin):
156163
logger: LoggerAdapter
157164
# Mapping of form {short string identifier -> message to show in reported
158165
# results}. This is a mapping and not a list to allow for changing of
159-
# some optimization messages throughout the course of the optimization (e.g. progress
160-
# report of the optimization).
166+
# some optimization messages throughout the course of the optimization
167+
# (e.g. progress report of the optimization).
161168
markdown_messages: Dict[str, str]
162169

163170
# Number of trials that existed on the scheduler's experiment before
@@ -684,8 +691,8 @@ def error_if_failure_rate_exceeded(self, force_check: bool = False) -> None:
684691
Args:
685692
force_check: Indicates whether to force a failure-rate check
686693
regardless of the number of trials that have been executed. If False
687-
(default), the check will be skipped if the optimization has fewer than five
688-
failed trials. If True, the check will be performed unless there
694+
(default), the check will be skipped if the optimization has fewer than
695+
five failed trials. If True, the check will be performed unless there
689696
are 0 failures.
690697
"""
691698
failed_idcs = self.experiment.trial_indices_by_status[TrialStatus.FAILED]
@@ -718,12 +725,12 @@ def error_if_failure_rate_exceeded(self, force_check: bool = False) -> None:
718725

719726
if failure_rate_exceeded:
720727
raise FailureRateExceededError(
721-
"Failure rate exceeds the tolerated trial failure rate of "
722-
f"{self.options.tolerated_trial_failure_rate} (at least "
723-
f"{num_failed_in_scheduler} out of first {num_ran_in_scheduler} trials "
724-
"failed). Checks are triggered both at the end of a optimization and if "
725-
f"at least {self.options.min_failed_trials_for_failure_rate_check} "
726-
"trials have failed."
728+
FAILURE_EXCEEDED_MSG.format(
729+
f_rate=self.options.tolerated_trial_failure_rate,
730+
n_failed=num_failed_in_scheduler,
731+
n_ran=num_ran_in_scheduler,
732+
min_failed=self.options.min_failed_trials_for_failure_rate_check,
733+
)
727734
)
728735

729736
def run_trials_and_yield_results(
@@ -1213,7 +1220,8 @@ def _complete_optimization(
12131220
res = self.wait_for_completed_trials_and_report_results(
12141221
idle_callback=idle_callback
12151222
)
1216-
# raise an error if the failure rate exceeds tolerance at the end of the optimization
1223+
# Raise an error if the failure rate exceeds tolerance at the
1224+
# end of the optimization.
12171225
self.error_if_failure_rate_exceeded(force_check=True)
12181226
self._record_run_trials_status(
12191227
num_preexisting_trials=num_preexisting_trials,

0 commit comments

Comments
 (0)