Add option to disable file logging

This commit is contained in:
Dominik Jain 2023-10-27 18:59:43 +02:00
parent a3dbe90515
commit 5952993cfe

View File

@ -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()}")