Skip to content

Commit f675e38

Browse files
committed
linting
1 parent ab9d7d5 commit f675e38

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

hydra_plugins/hyper_smac/hyper_smac.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
from copy import deepcopy
65
from pathlib import Path
76

87
import pandas as pd
@@ -65,11 +64,12 @@ def ask(self):
6564
optimizer_termination = True
6665
print("All brackets finished. Optimization will terminate.")
6766

68-
if not self.brackets_finished:
69-
if self.total_configs >= sum(self.smac._intensifier._n_configs_in_stage[self.current_bracket]):
70-
self.current_bracket += 1
71-
self.total_configs = 0
72-
terminate = True
67+
if not self.brackets_finished and self.total_configs >= sum(
68+
self.smac._intensifier._n_configs_in_stage[self.current_bracket]
69+
):
70+
self.current_bracket += 1
71+
self.total_configs = 0
72+
terminate = True
7373

7474
return info, terminate, optimizer_termination
7575

hydra_plugins/hypersweeper/hypersweeper_sweeper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def run(self, verbose=False):
472472

473473
try:
474474
pass
475-
#info, terminate, optimizer_termination = self.optimizer.ask()
475+
# info, terminate, optimizer_termination = self.optimizer.ask()
476476
except Exception as e: # noqa: BLE001
477477
if len(infos) > 0:
478478
print("Optimizer failed on ask - running remaining configs.")

tests/test_runs/test_smac.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_smac_hyperband_termination():
5050
# Goal: first launch 13 jobs in bracket 1, then 6 in bracket 2, then 3 in bracket 3, then 2 and terminate
5151
keyword = "Launching "
5252
all_keyword_indices = [m.start() for m in re.finditer(keyword, process_logs)]
53-
n_jobs_spawned = [int(process_logs[occ + len(keyword):occ + len(keyword)+2]) for occ in all_keyword_indices]
53+
n_jobs_spawned = [int(process_logs[occ + len(keyword) : occ + len(keyword) + 2]) for occ in all_keyword_indices]
5454
total_jobs_spawned = sum(n_jobs_spawned)
5555

5656
assert total_jobs_spawned == 20, (
@@ -68,6 +68,7 @@ def test_smac_hyperband_termination():
6868

6969
shutil.rmtree(Path("mlp_smac_hyperband"))
7070

71+
7172
def test_smac_hyperband_optimizer_termination():
7273
if Path("mlp_smac_hyperband").exists():
7374
shutil.rmtree(Path("mlp_smac_hyperband"))
@@ -88,13 +89,11 @@ def test_smac_hyperband_optimizer_termination():
8889
# Goal: first launch 13 jobs in bracket 1, then 6 in bracket 2, then 3 in bracket 3, then 2 and terminate
8990
keyword = "Launching "
9091
all_keyword_indices = [m.start() for m in re.finditer(keyword, process_logs)]
91-
n_jobs_spawned = [int(process_logs[occ + len(keyword):occ + len(keyword)+2]) for occ in all_keyword_indices]
92+
n_jobs_spawned = [int(process_logs[occ + len(keyword) : occ + len(keyword) + 2]) for occ in all_keyword_indices]
9293
total_jobs_spawned = sum(n_jobs_spawned)
9394
print(n_jobs_spawned)
9495

95-
assert total_jobs_spawned == 23, (
96-
f"Optimizer termination not happening. Used: {total_jobs_spawned}, expected: 23."
97-
)
96+
assert total_jobs_spawned == 23, f"Optimizer termination not happening. Used: {total_jobs_spawned}, expected: 23."
9897
assert n_jobs_spawned[0] == 13, (
9998
f"Number of spawned jobs in bracket 1 is incorrect. Used: {n_jobs_spawned[0]}, expected: 13."
10099
)

0 commit comments

Comments
 (0)