From 5952993cfee402632ceb309a6b8690cfeb78bdf1 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Fri, 27 Oct 2023 18:59:43 +0200 Subject: [PATCH] Add option to disable file logging --- tianshou/highlevel/experiment.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tianshou/highlevel/experiment.py b/tianshou/highlevel/experiment.py index 0ef81a3..cbea70e 100644 --- a/tianshou/highlevel/experiment.py +++ b/tianshou/highlevel/experiment.py @@ -108,6 +108,9 @@ class ExperimentConfig: in this directory based on the run's experiment name""" persistence_enabled: bool = True """Whether persistence is enabled, allowing files to be stored""" + log_file_enabled: bool = True + """Whether to write to a log file; has no effect if `persistence_enabled` is False. + Disable this if you have externally configured log file generation.""" policy_persistence_mode: PolicyPersistence.Mode = PolicyPersistence.Mode.POLICY """Controls the way in which the policy is persisted""" @@ -205,7 +208,7 @@ class Experiment(ToStringMixin): with logging.FileLoggerContext( os.path.join(persistence_dir, self.LOG_FILENAME), - enabled=use_persistence, + enabled=use_persistence and self.config.log_file_enabled, ): # log initial information log.info(f"Running experiment (name='{experiment_name}'):\n{self.pprints()}")