Skip to content
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

[BUG-FIX] WandbLogger _sanitize_callable #4422

Merged
merged 5 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytorch_lightning/loggers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def _sanitize_callable(val):
return val.__name__
return _val
except Exception:
return val.__name__
return getattr(val, "__name__", None)
return val

return {key: _sanitize_callable(val) for key, val in params.items()}
Expand Down
5 changes: 4 additions & 1 deletion tests/loggers/test_wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from pytorch_lightning import Trainer
from pytorch_lightning.loggers import WandbLogger
from tests.base import EvalModelTemplate
from tests.base import EvalModelTemplate, BoringModel


@mock.patch('pytorch_lightning.loggers.wandb.wandb')
Expand Down Expand Up @@ -135,6 +135,8 @@ def return_something():

def wrapper_something():
return return_something

params.wrapper_something_wo_name = lambda: lambda: '1'
params.wrapper_something = wrapper_something

assert isinstance(params.gpus, types.FunctionType)
Expand All @@ -144,3 +146,4 @@ def wrapper_something():
assert params["gpus"] == '_gpus_arg_default'
assert params["something"] == "something"
assert params["wrapper_something"] == "wrapper_something"
assert params["wrapper_something_wo_name"] == "<lambda>"