Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nabenabe0928 committed Oct 25, 2024
1 parent 7e75683 commit e7362a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 5 additions & 3 deletions package/samplers/auto_sampler/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import TYPE_CHECKING

from optuna.distributions import CategoricalDistribution
from optuna.logging import get_logger
from optuna.samplers import BaseSampler
from optuna.samplers import CmaEsSampler
from optuna.samplers import GPSampler
Expand All @@ -27,6 +28,7 @@

MAXINT32 = (1 << 31) - 1
SAMPLER_KEY = "auto:sampler"
_logger = get_logger(f"optuna.{__name__}")


class _ThreadLocalSampler(threading.local):
Expand Down Expand Up @@ -197,9 +199,9 @@ def before_trial(self, study: Study, trial: FrozenTrial) -> None:
search_space = IntersectionSearchSpace().calculate(study)
self._sampler = self._determine_sampler(study, trial, search_space)

study._storage.set_trial_system_attr(
trial._trial_id, SAMPLER_KEY, self._sampler.__class__.__name__
)
sampler_name = self._sampler.__class__.__name__
_logger.debug(f"Sample trial#{trial.number} with {sampler_name}.")
study._storage.set_trial_system_attr(trial._trial_id, SAMPLER_KEY, sampler_name)
self._sampler.before_trial(study, trial)

def after_trial(
Expand Down
3 changes: 1 addition & 2 deletions package/samplers/auto_sampler/tests/test_auto_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@


# TODO(nabaenabe): Add the CI for this sampler.
optuna.logging.set_verbosity(optuna.logging.CRITICAL)

# optuna.logging.set_verbosity(optuna.logging.CRITICAL)

AutoSampler = optunahub.load_local_module(
package="samplers/auto_sampler", registry_root="package/"
Expand Down

0 comments on commit e7362a0

Please sign in to comment.