Skip to content

Commit

Permalink
Checking if the parameters are a DictConfig Object (#2216)
Browse files Browse the repository at this point in the history
* Checking if the parameters are a DictConfig Object

This is in reference to #2058 . 

To be honest, I have no idea how I should go about writing a test for this.

* Update pytorch_lightning/loggers/base.py

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>

* fix ...

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Jirka <jirka@pytorchlightning.ai>
  • Loading branch information
3 people committed Jun 23, 2020
1 parent bdee1cd commit 44385bb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pytorch_lightning/loggers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import operator
from abc import ABC, abstractmethod
from argparse import Namespace
from typing import Union, Optional, Dict, Iterable, Any, Callable, List, Sequence, Mapping, Tuple
from typing import Union, Optional, Dict, Iterable, Any, Callable, List, Sequence, Mapping, Tuple, MutableMapping

import numpy as np
import torch

from pytorch_lightning.utilities import rank_zero_only


class LightningLoggerBase(ABC):
"""
Expand Down Expand Up @@ -174,9 +172,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, MutableMapping):
for key, value in input_dict.items():
if isinstance(value, (dict, Namespace)):
if isinstance(value, (MutableMapping, 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 44385bb

Please sign in to comment.