Skip to content

Commit

Permalink
improve flakey test reliability
Browse files Browse the repository at this point in the history
Summary: set seeds to reduce flakiness

Reviewed By: bernardbeckerman

Differential Revision: D54508799
  • Loading branch information
sdaulton authored and facebook-github-bot committed Mar 5, 2024
1 parent d3f464d commit c5aaae1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ax/core/tests/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
from typing import Dict, List, Type
from unittest.mock import MagicMock, patch

import numpy as np

import pandas as pd
import torch
from ax.core import BatchTrial, Trial
from ax.core.arm import Arm
from ax.core.base_trial import TrialStatus
Expand Down Expand Up @@ -1388,10 +1391,15 @@ def test_WarmStartMapData(self) -> None:
@fast_botorch_optimize
def test_batch_with_multiple_generator_runs(self) -> None:
exp = get_branin_experiment()
sobol = Models.SOBOL(experiment=exp, search_space=exp.search_space)
# set seed to avoid transient errors caused by duplicate arms,
# which leads to fewer arms in the trial than expected.
seed = 0
sobol = Models.SOBOL(experiment=exp, search_space=exp.search_space, seed=seed)
exp.new_batch_trial(generator_runs=[sobol.gen(n=7)]).run().complete()

data = exp.fetch_data()
torch.manual_seed(seed)
np.random.seed(seed)
gp = Models.BOTORCH_MODULAR(
experiment=exp, search_space=exp.search_space, data=data
)
Expand Down

0 comments on commit c5aaae1

Please sign in to comment.