-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typing: make CSVLogger name
optional str
#19433
Comments
@mwip Can you explain why the Optional annotation is needed?
So I would prefer to clearly indicate the default value and leave it as is. |
@awaelchli Forgive my confusion, but I'm not able to find the line you are referring to. Maybe you'd be able to link it? Also, this seems to differ from the behavior of this minimal example: import lightning
csv_logger1 = lightning.pytorch.loggers.csv_logs.CSVLogger(save_dir="save_dir")
csv_logger2 = lightning.pytorch.loggers.csv_logs.CSVLogger(save_dir="save_dir", name=None)
csv_logger3 = lightning.pytorch.loggers.csv_logs.CSVLogger(save_dir="save_dir", name="some_name")
print(f"{csv_logger1.name=}")
# csv_logger1.name='lightning_logs'
print(f"{csv_logger2.name=}")
# csv_logger2.name=''
print(f"{csv_logger3.name=}")
# csv_logger3.name='some_name'
print(f"{csv_logger1.log_dir=}")
# csv_logger1.log_dir='save_dir/lightning_logs/version_0'
print(f"{csv_logger2.log_dir=}")
# csv_logger2.log_dir='save_dir/version_0' Or am I missing something? |
Ok, I initially thought you wanted to make the argument optional in the literal sense (i.e. making the default None). But I should have read more carefully. I am ok with your proposed change if it's just about adding |
This patch adds `Optional` typing to the `name` parameter in `CSVLogger` reflecting the actual behavior. This increases coherence with other loggers and helps with type checking. Additionally documentation is improved. This patch does NOT change the underlying behavior. Hence no additional tests were added. Tests already can be found in tests/tests_pytorch/loggers/test_csv.py#L85-L90 Closes Lightning-AI#19433
Bug description
Currently,
lightning.pytorch.loggers.csv_logs.CSVLogger(name: str, ...)
the parametername
of the CSVLogger ist typed asstr
.pytorch-lightning/src/lightning/pytorch/loggers/csv_logs.py
Line 97 in 9c8cd4c
This contrasts other loggers, e.g.
TensorBoardLogger
orWandbLogger
.I suggest typing
CSVLogger(name: Optional[str], ...)
as it is ineed optional:pytorch-lightning/src/lightning/fabric/loggers/csv_logs.py
Line 69 in 9c8cd4c
What version are you seeing the problem on?
master
How to reproduce the bug
Error messages and logs
cc @Borda
The text was updated successfully, but these errors were encountered: