From 0235543ffe6147f5aaf33c9e092cd28e05beda7c Mon Sep 17 00:00:00 2001 From: Matthias Weigand Date: Fri, 23 Feb 2024 20:31:38 +0100 Subject: [PATCH] Make `CSVLogger(name: ...)` optional `str` (#19518) --- src/lightning/fabric/loggers/csv_logs.py | 5 +++-- src/lightning/pytorch/loggers/csv_logs.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lightning/fabric/loggers/csv_logs.py b/src/lightning/fabric/loggers/csv_logs.py index 6079c61d29cd2..9e82041b528c1 100644 --- a/src/lightning/fabric/loggers/csv_logs.py +++ b/src/lightning/fabric/loggers/csv_logs.py @@ -37,7 +37,8 @@ class CSVLogger(Logger): Args: root_dir: The root directory in which all your experiments with different names and versions will be stored. - name: Experiment name. Defaults to ``'lightning_logs'``. + name: Experiment name. Defaults to ``'lightning_logs'``. If name is ``None``, logs + (versions) will be stored to the save dir directly. version: Experiment version. If version is not specified the logger inspects the save directory for existing versions, then automatically assigns the next available version. If the version is specified, and the directory already contains a metrics file for that version, it will be @@ -60,7 +61,7 @@ class CSVLogger(Logger): def __init__( self, root_dir: _PATH, - name: str = "lightning_logs", + name: Optional[str] = "lightning_logs", version: Optional[Union[int, str]] = None, prefix: str = "", flush_logs_every_n_steps: int = 100, diff --git a/src/lightning/pytorch/loggers/csv_logs.py b/src/lightning/pytorch/loggers/csv_logs.py index d86249bd9ff6f..fdaeb18e9199f 100644 --- a/src/lightning/pytorch/loggers/csv_logs.py +++ b/src/lightning/pytorch/loggers/csv_logs.py @@ -82,7 +82,8 @@ class CSVLogger(Logger, FabricCSVLogger): Args: save_dir: Save directory - name: Experiment name. Defaults to ``'lightning_logs'``. + name: Experiment name, optional. Defaults to ``'lightning_logs'``. If name is ``None``, logs + (versions) will be stored to the save dir directly. version: Experiment version. If version is not specified the logger inspects the save directory for existing versions, then automatically assigns the next available version. prefix: A string to put at the beginning of metric keys. @@ -95,7 +96,7 @@ class CSVLogger(Logger, FabricCSVLogger): def __init__( self, save_dir: _PATH, - name: str = "lightning_logs", + name: Optional[str] = "lightning_logs", version: Optional[Union[int, str]] = None, prefix: str = "", flush_logs_every_n_steps: int = 100,