Skip to content

Commit d3506d4

Browse files
committed
[fix] Change f-string to format in base_task.py
1 parent d0a7130 commit d3506d4

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

autoPyTorch/api/base_task.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -852,9 +852,10 @@ def _search(
852852
time_left_for_modelfit = int(max(0, total_walltime_limit - elapsed_time))
853853
if func_eval_time_limit_secs is None or func_eval_time_limit_secs > time_left_for_modelfit:
854854
self._logger.warning(
855-
'Time limit for a single run is higher than total time '
856-
'limit. Capping the limit for a single run to the total '
857-
'time given to SMAC (%f)' % time_left_for_modelfit
855+
"Time limit for a single run exceeded total time limit. "
856+
"Cap the limit for a single run to the total time given to SMAC ({})".format(
857+
time_left_for_modelfit
858+
)
858859
)
859860
func_eval_time_limit_secs = time_left_for_modelfit
860861

@@ -863,10 +864,8 @@ def _search(
863864
if num_models < 2:
864865
func_eval_time_limit_secs = time_left_for_modelfit // 2
865866
self._logger.warning(
866-
"Capping the func_eval_time_limit_secs to {} to have "
867-
"time for a least 2 models to ensemble.".format(
868-
func_eval_time_limit_secs
869-
)
867+
"Cap the func_eval_time_limit_secs to {} to guarantee at least"
868+
"two model-trainings".format(func_eval_time_limit_secs)
870869
)
871870

872871
# ============> Run dummy predictions
@@ -879,7 +878,7 @@ def _search(
879878

880879
if enable_traditional_pipeline:
881880
if STRING_TO_TASK_TYPES[self.task_type] in REGRESSION_TASKS:
882-
self._logger.warning("Traditional Pipeline is not enabled for regression. Skipping...")
881+
self._logger.warning("Regression tasks are not supported by traditional pipelines. Skip...")
883882
else:
884883
traditional_task_name = 'runTraditional'
885884
self._stopwatch.start_task(traditional_task_name)
@@ -906,9 +905,9 @@ def _search(
906905
"is no time left. Try increasing the value "
907906
"of time_left_for_this_task.")
908907
elif self.ensemble_size <= 0:
909-
self._logger.info("Not starting ensemble builder as ensemble size is 0")
908+
self._logger.info("Skip ensemble builder as the provided ensemble size is 0.")
910909
else:
911-
self._logger.info("Starting ensemble")
910+
self._logger.info("Start building ensemble.")
912911
ensemble_task_name = 'ensemble'
913912
self._stopwatch.start_task(ensemble_task_name)
914913
proc_ensemble = EnsembleBuilderManager(
@@ -939,9 +938,9 @@ def _search(
939938
elapsed_time = self._stopwatch.wall_elapsed(experiment_task_name)
940939
time_left_for_smac = max(0, total_walltime_limit - elapsed_time)
941940

942-
self._logger.info("Starting SMAC with %5.2f sec time left" % time_left_for_smac)
941+
self._logger.info("Start SMAC with {:.2f} [sec] time left".format(time_left_for_smac))
943942
if time_left_for_smac <= 0:
944-
self._logger.warning(" Not starting SMAC because there is no time left")
943+
self._logger.warning("Skip SMAC because there is no time left")
945944
else:
946945

947946
_proc_smac = AutoMLSMBO(
@@ -984,43 +983,43 @@ def _search(
984983
with open(trajectory_filename, 'w') as fh:
985984
json.dump(saveable_trajectory, fh)
986985
except Exception as e:
987-
self._logger.warning(f"Cannot save {trajectory_filename} due to {e}...")
986+
self._logger.warning("Cannot save {} due to {}".format(trajectory_filename, e))
988987
except Exception as e:
989988
self._logger.exception(str(e))
990989
raise
991990
# Wait until the ensemble process is finished to avoid shutting down
992991
# while the ensemble builder tries to access the data
993-
self._logger.info("Starting Shutdown")
992+
self._logger.info("Start shutdown")
994993

995994
if proc_ensemble is not None:
996995
self.ensemble_performance_history = list(proc_ensemble.history)
997996

998997
if len(proc_ensemble.futures) > 0:
999998
# Also add ensemble runs that did not finish within smac time
1000999
# and add them into the ensemble history
1001-
self._logger.info("Ensemble script still running, waiting for it to finish.")
1000+
self._logger.info("Wait until all the ensemble processes finish")
10021001
result = proc_ensemble.futures.pop().result()
10031002
if result:
10041003
ensemble_history, _, _, _ = result
10051004
self.ensemble_performance_history.extend(ensemble_history)
1006-
self._logger.info("Ensemble script finished, continue shutdown.")
1005+
self._logger.info("Finish all the ensemble processes and start shutdown")
10071006

10081007
# save the ensemble performance history file
10091008
if len(self.ensemble_performance_history) > 0:
10101009
pd.DataFrame(self.ensemble_performance_history).to_json(
10111010
os.path.join(self._backend.internals_directory, 'ensemble_history.json'))
10121011

1013-
self._logger.info("Closing the dask infrastructure")
1012+
self._logger.info("Close the dask infrastructure")
10141013
self._close_dask_client()
1015-
self._logger.info("Finished closing the dask infrastructure")
1014+
self._logger.info("Finish closing the dask infrastructure")
10161015

10171016
if load_models:
1018-
self._logger.info("Loading models...")
1017+
self._logger.info("Load models")
10191018
self._load_models()
1020-
self._logger.info("Finished loading models...")
1019+
self._logger.info("Finish loading models")
10211020

10221021
# Clean up the logger
1023-
self._logger.info("Starting to clean up the logger")
1022+
self._logger.info("Clean up the logger")
10241023
self._clean_logger()
10251024

10261025
return self
@@ -1294,10 +1293,11 @@ def _print_debug_info_to_log(self) -> None:
12941293
Prints to the log file debug information about the current estimator
12951294
"""
12961295
assert self._logger is not None
1297-
self._logger.debug("Starting to print environment information")
1298-
self._logger.debug(' Python version: %s', sys.version.split('\n'))
1299-
self._logger.debug(' System: %s', platform.system())
1300-
self._logger.debug(' Machine: %s', platform.machine())
1301-
self._logger.debug(' Platform: %s', platform.platform())
1296+
self._logger.debug("Display environment information")
1297+
self._logger.debug(" Python version: {}".format(sys.version.split('\n')))
1298+
self._logger.debug(" System: {}".format(platform.system()))
1299+
self._logger.debug(" Machine: {}".format(platform.machine()))
1300+
self._logger.debug(" Platform: {}".format(platform.platform()))
1301+
13021302
for key, value in vars(self).items():
1303-
self._logger.debug(f"\t{key}->{value}")
1303+
self._logger.debug("\t{}->{}".format(key, value))

0 commit comments

Comments
 (0)