Skip to content

Commit

Permalink
Fix tests again (facebook#593)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: facebook#593

Reviewed By: bernardbeckerman

Differential Revision: D29041343

fbshipit-source-id: 5d5387917d69a82fd54a6a8aa9d2d4ce7bf92aab
  • Loading branch information
ldworkin authored and facebook-github-bot committed Jun 10, 2021
1 parent fe37ff8 commit 81955e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion ax/service/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from __future__ import annotations

import itertools
from abc import ABC, abstractmethod
from collections import defaultdict
from dataclasses import dataclass
Expand Down
15 changes: 12 additions & 3 deletions ax/service/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from math import ceil
from random import randint
from tempfile import NamedTemporaryFile
from typing import Any, Dict, Iterable, Optional, Set, Tuple
from typing import Any, Dict, Iterable, Set, Tuple
from unittest.mock import patch

from ax.core.base_trial import BaseTrial, TrialStatus
Expand Down Expand Up @@ -201,6 +201,15 @@ def test_validate_runners_if_required(self):
scheduler.run_all_trials()

def test_validate_early_stopping_strategy(self):
class DummyEarlyStoppingStrategy(BaseEarlyStoppingStrategy):
def should_stop_trials_early(
self,
trial_indices: Set[int],
experiment: Experiment,
**kwargs: Dict[str, Any],
) -> Set[int]:
return {}

with patch(
f"{BraninMetric.__module__}.BraninMetric.is_available_while_running",
return_value=False,
Expand All @@ -209,7 +218,7 @@ def test_validate_early_stopping_strategy(self):
experiment=self.branin_experiment,
generation_strategy=self.sobol_GPEI_GS,
options=SchedulerOptions(
early_stopping_strategy=BaseEarlyStoppingStrategy()
early_stopping_strategy=DummyEarlyStoppingStrategy()
),
)

Expand All @@ -218,7 +227,7 @@ def test_validate_early_stopping_strategy(self):
experiment=self.branin_experiment,
generation_strategy=self.sobol_GPEI_GS,
options=SchedulerOptions(
early_stopping_strategy=BaseEarlyStoppingStrategy()
early_stopping_strategy=DummyEarlyStoppingStrategy()
),
)

Expand Down

0 comments on commit 81955e2

Please sign in to comment.