def _init_valid(self) -> None: self._progress_bar = tqdm(range(self._n_trials) if self._n_trials is not None else None) global _tqdm_handler _tqdm_handler = _TqdmLoggingHandler() _tqdm_handler.setLevel(logging.INFO) _tqdm_handler.setFormatter(optuna_logging.create_default_formatter()) optuna_logging.disable_default_handler() optuna_logging._get_library_root_logger().addHandler(_tqdm_handler)
def _init_valid(self) -> None: if self._n_trials is not None: self._progress_bar = tqdm(total=self._n_trials) else: fmt = "{percentage:3.0f}%|{bar}| {elapsed}/{desc}" self._progress_bar = tqdm(total=self._timeout, bar_format=fmt) # Using description string instead postfix string # to display formatted timeout, since postfix carries # extra comma space auto-format. # https://github.com/tqdm/tqdm/issues/712 total = tqdm.format_interval(self._timeout) self._progress_bar.set_description_str(total) global _tqdm_handler _tqdm_handler = _TqdmLoggingHandler() _tqdm_handler.setLevel(logging.INFO) _tqdm_handler.setFormatter(optuna_logging.create_default_formatter()) optuna_logging.disable_default_handler() optuna_logging._get_library_root_logger().addHandler(_tqdm_handler)