Skip to content

Commit

Permalink
Checking if the parameters are a DictConfig Object
Browse files Browse the repository at this point in the history
This is in reference to Lightning-AI#2058 . 

To be honest, I have no idea how I should go about writing a test for this.
  • Loading branch information
ssakhavi authored and Borda committed Jun 19, 2020
1 parent 54acc79 commit 6709088
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pytorch_lightning/loggers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import torch

from pytorch_lightning.utilities import rank_zero_only
from omegaconf import DictConfig


class LightningLoggerBase(ABC):
Expand Down Expand Up @@ -174,9 +175,9 @@ def _flatten_dict(params: Dict[str, Any], delimiter: str = '/') -> Dict[str, Any

def _dict_generator(input_dict, prefixes=None):
prefixes = prefixes[:] if prefixes else []
if isinstance(input_dict, dict):
if isinstance(input_dict, (dict, DictConfig)):
for key, value in input_dict.items():
if isinstance(value, (dict, Namespace)):
if isinstance(value, (dict, DictConfig, Namespace)):
value = vars(value) if isinstance(value, Namespace) else value
for d in _dict_generator(value, prefixes + [key]):
yield d
Expand Down

0 comments on commit 6709088

Please sign in to comment.