Skip to content

Commit d0848b7

Browse files
oprypincopybara-github
authored andcommitted
Replace # pytype: disable supprressions with # pyrefly: ignore
PiperOrigin-RevId: 993590179
1 parent 5638be6 commit d0848b7

24 files changed

Lines changed: 74 additions & 73 deletions

‎demos/run_vizier_server.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def main(argv: Sequence[str]) -> None:
5959
raise app.UsageError('Too many command-line arguments.')
6060

6161
server = servers.DefaultVizierServer(
62-
host=FLAGS.host, database_url=FLAGS.database_url # pyrefly: ignore[unexpected-keyword]
62+
host=FLAGS.host, database_url=FLAGS.database_url
6363
)
6464
logging.info('Address to Vizier Server is: %s', server.endpoint)
6565

‎vizier/_src/algorithms/classification/classifiers.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ def __call__(self) -> np.ndarray:
9292
if self.eval_metric == 'probability':
9393
return self.classifier.predict_proba(np.asarray(self.features_test))[:, 1]
9494
else:
95-
return self.classifier.decision_function(np.asarray(self.features_test)) # pytype:disable=attribute-error
95+
return self.classifier.decision_function(np.asarray(self.features_test)) # pyrefly: ignore[missing-attribute]

‎vizier/_src/algorithms/designers/eagle_strategy/eagle_strategy.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def __init__(
146146
self._rng = np.random.default_rng(seed=seed)
147147
self._config = config or FireflyAlgorithmConfig()
148148
self._utils = EagleStrategyUtils(self._problem, self._config, self._rng)
149-
self._firefly_pool = FireflyPool( # pyrefly: ignore[missing-argument]
150-
utils=self._utils, capacity=self._utils.compute_pool_capacity() # pyrefly: ignore[unexpected-keyword]
149+
self._firefly_pool = FireflyPool(
150+
utils=self._utils, capacity=self._utils.compute_pool_capacity()
151151
)
152152

153153
if initial_designer_factory is None:

‎vizier/_src/algorithms/designers/eagle_strategy/eagle_strategy_utils.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def get_metric(self, trial: vz.Trial) -> float:
361361
return np.nan
362362
if trial.final_measurement is None:
363363
raise ValueError('Trial is not completed.')
364-
return trial.final_measurement.metrics[OBJECTIVE_NAME] # pytype: disable=bad-return-type
364+
return trial.final_measurement.metrics[OBJECTIVE_NAME]
365365

366366
def is_better_than(
367367
self,

‎vizier/_src/algorithms/designers/gp/gp_models_test.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _setup_lambda_search(
6666
problem = vz.ProblemStatement(
6767
search_space=search_space,
6868
metric_information=vz.MetricsConfig(
69-
metrics=[ # pyrefly: ignore[unexpected-keyword]
69+
metrics=[
7070
vz.MetricInformation('obj', goal=vz.ObjectiveMetricGoal.MAXIMIZE),
7171
]
7272
),
@@ -378,7 +378,7 @@ def test_multi_task(self, multitask_type: mt_type):
378378
problem = vz.ProblemStatement(
379379
search_space=search_space,
380380
metric_information=vz.MetricsConfig(
381-
metrics=[ # pyrefly: ignore[unexpected-keyword]
381+
metrics=[
382382
vz.MetricInformation(
383383
'obj1', goal=vz.ObjectiveMetricGoal.MAXIMIZE
384384
),

‎vizier/_src/algorithms/designers/gp/output_warpers.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,10 @@ def warp(self, labels_arr: types.Array) -> types.Array:
357357
labels_arr[i] = rank_ppf * estimated_std + median
358358

359359
# Save information needed for unwarping.
360-
self._unwarper = _HalfRankUnwarper( # pyrefly: ignore[missing-argument]
361-
original_labels=unique_labels, # pyrefly: ignore[unexpected-keyword]
362-
warped_labels=labels_arr[is_finite][unique_idx], # pyrefly: ignore[bad-argument-type, unexpected-keyword]
363-
original_label_median=unique_labels[len(unique_labels) // 2], # pyrefly: ignore[unexpected-keyword]
360+
self._unwarper = _HalfRankUnwarper(
361+
original_labels=unique_labels,
362+
warped_labels=labels_arr[is_finite][unique_idx], # pyrefly: ignore[bad-argument-type]
363+
original_label_median=unique_labels[len(unique_labels) // 2],
364364
)
365365
return labels_arr[:, np.newaxis]
366366

‎vizier/_src/algorithms/designers/meta_learning/meta_learning.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ def __attrs_post_init__(self):
157157
self.seed = np.random.randint(low=0, high=1e6) # pyrefly: ignore[no-matching-overload]
158158

159159
# Instantiate an MetaLearningUtils.
160-
self._utils = utils.MetaLearningUtils( # pyrefly: ignore[missing-argument]
161-
goal=self.problem.metric_information.item().goal, # pyrefly: ignore[unexpected-keyword]
162-
tuned_metric_name=self.problem.metric_information.item().name, # pyrefly: ignore[unexpected-keyword]
163-
meta_metric_name=self._meta_designer_metric_name, # pyrefly: ignore[unexpected-keyword]
164-
tuning_params=self.tuning_hyperparams, # pyrefly: ignore[unexpected-keyword]
160+
self._utils = utils.MetaLearningUtils(
161+
goal=self.problem.metric_information.item().goal,
162+
tuned_metric_name=self.problem.metric_information.item().name,
163+
meta_metric_name=self._meta_designer_metric_name,
164+
tuning_params=self.tuning_hyperparams,
165165
)
166166
# Instantiated 'tuned' designer the with default hyper-parameters.
167167
self._curr_tuned_hyperparams = self._utils.get_default_hyperparameters()

‎vizier/_src/algorithms/designers/meta_learning/meta_learning_utils.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def meta_problem(self) -> vz.ProblemStatement:
3838
"""Create meta problem."""
3939
problem = vz.ProblemStatement(search_space=self._tuning_params)
4040
problem.metric_information = vz.MetricsConfig(
41-
metrics=[vz.MetricInformation(self._meta_metric_name, goal=self._goal)] # pyrefly: ignore[unexpected-keyword]
41+
metrics=[vz.MetricInformation(self._meta_metric_name, goal=self._goal)]
4242
)
4343
return problem
4444

‎vizier/_src/algorithms/designers/meta_learning/meta_learning_utils_test.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def setUp(self):
2929
super().setUp()
3030
space = vz.SearchSpace()
3131
space.root.add_int_param('tuned_param', 0, 100, default_value=55)
32-
self.utils = meta_learning_utils.MetaLearningUtils( # pyrefly: ignore[missing-argument]
33-
goal=vz.ObjectiveMetricGoal.MAXIMIZE, # pyrefly: ignore[unexpected-keyword]
34-
tuned_metric_name='tuned_obj', # pyrefly: ignore[unexpected-keyword]
35-
meta_metric_name='meta_obj', # pyrefly: ignore[unexpected-keyword]
36-
tuning_params=space, # pyrefly: ignore[unexpected-keyword]
32+
self.utils = meta_learning_utils.MetaLearningUtils(
33+
goal=vz.ObjectiveMetricGoal.MAXIMIZE,
34+
tuned_metric_name='tuned_obj',
35+
meta_metric_name='meta_obj',
36+
tuning_params=space,
3737
)
3838
self.meta_trials = []
3939
for i in range(10):

‎vizier/_src/algorithms/ensemble/ensemble_design.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def update(self, observation: IndexWithReward): # pyrefly: ignore[bad-override]
9797
self._history.append(observation)
9898

9999

100-
# pytype: disable=attribute-error
101100
# https://www.cs.princeton.edu/courses/archive/fall16/cos402/lectures/402-lec22.pdf.
102101
@attrs.define
103102
class EXP3UniformEnsembleDesign(EnsembleDesign):
@@ -129,7 +128,7 @@ def ensemble_probs(self) -> np.ndarray:
129128
probs = (1 - gamma) * softmax(self._log_weights) + gamma * uniform
130129
return probs
131130

132-
def update(self, observation: IndexWithReward):
131+
def update(self, observation: IndexWithReward): # pyrefly: ignore[bad-override]
133132
"""Update history and weights."""
134133
expert_idx, reward = observation
135134
if not self.use_reward_estimator:
@@ -242,7 +241,7 @@ def observation_probs(self) -> np.ndarray:
242241
) + algo_prob_sum / (2 * np.sum(algo_prob_sum))
243242
return observation_prob
244243

245-
def update(self, observation: IndexWithReward):
244+
def update(self, observation: IndexWithReward): # pyrefly: ignore[bad-override]
246245
expert_idx, reward = observation
247246
reward = min(reward, self.max_reward)
248247
reward_estimator = reward * 1.0 / self.ensemble_probs[expert_idx]
@@ -278,6 +277,3 @@ def update(self, observation: IndexWithReward):
278277
base_algo.update((expert_idx, reward_estimator))
279278

280279
self._history.append(observation)
281-
282-
283-
# pytype: enable=attribute-error

0 commit comments

Comments
 (0)