8000 Fix the flag error in runtime context. https://github.com/google/vizier/issues/698 by copybara-service[bot] · Pull Request #700 · google/vizier · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions vizier/_src/service/vizier_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from google.protobuf import duration_pb2
from google.protobuf import json_format

flags.DEFINE_integer(
_VIZIER_NEW_SUGGESTION_POLLING_SECONDS = flags.DEFINE_integer(
'vizier_new_suggestion_polling_secs',
1,
(
Expand All @@ -56,6 +56,14 @@
FLAGS = flags.FLAGS


# TODO: Add an e2e test for this.
def _get_new_suggestion_polling_secs() -> int:
if FLAGS.is_parsed():
return _VIZIER_NEW_SUGGESTION_POLLING_SECONDS.value
else:
return int(_VIZIER_NEW_SUGGESTION_POLLING_SECONDS.default)


@attr.define
class _EnvironmentVariables:
server_endpoint: str = attr.field(
Expand Down Expand Up @@ -165,7 +173,7 @@ def get_suggestions(
num_attempts = 0
while not operation.done:
sleep_time = PollingDelay(
num_attempts, FLAGS.vizier_new_suggestion_polling_secs
num_attempts, _get_new_suggestion_polling_secs()
)
num_attempts += 1
logging.info(
Expand Down
17 changes: 9 additions & 8 deletions vizier/_src/service/vizier_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
# add_trial, OR turn it into a private module

from typing import List
from absl import logging

from absl import logging
from vizier._src.service import constants
from vizier._src.service import resources
from vizier._src.service import study_pb2
Expand Down Expand Up @@ -220,17 +220,18 @@ def test_get_suggestions(self):
# Only test algorithms which don't depend on external libraries (except for
# numpy).
@parameterized.parameters(
(pyvizier.Algorithm.RANDOM_SEARCH, 50, 1, False),
(pyvizier.Algorithm.QUASI_RANDOM_SEARCH, 50, 1, False),
(pyvizier.Algorithm.GRID_SEARCH, 50, 1, False),
(pyvizier.Algorithm.NSGA2, 50, 1, True),
dict(algorithm=pyvizier.Algorithm.RANDOM_SEARCH),
dict(algorithm=pyvizier.Algorithm.QUASI_RANDOM_SEARCH),
dict(algorithm=pyvizier.Algorithm.GRID_SEARCH),
dict(algorithm=pyvizier.Algorithm.NSGA2, multi_objective=True),
)
def test_e2e_tuning(
self,
*,
algorithm,
num_iterations: int,
batch_size: int,
multi_objective: bool,
num_iterations: int = 50,
batch_size: int = 1,
multi_objective: bool = False,
):
# Runs end-to-end tuning via back-and-forth communication to server.
def learning_curve_generator(learning_rate: float) -> List[float]:
Expand Down
0