Skip to content

Commit

Permalink
Merge 18d030e into b44048a
Browse files Browse the repository at this point in the history
  • Loading branch information
HAOCHENYE committed Dec 20, 2022
2 parents b44048a + 18d030e commit 9567c25
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions mmengine/logging/message_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,18 @@ def update_scalars(self, log_dict: dict, resumed: bool = True) -> None:
assert isinstance(log_dict, dict), ('`log_dict` must be a dict!, '
f'but got {type(log_dict)}')
for log_name, log_val in log_dict.items():
self._set_resumed_keys(log_name, resumed)
if isinstance(log_val, dict):
assert 'value' in log_val, \
f'value must be defined in {log_val}'
count = self._get_valid_value(log_val.get('count', 1))
checked_value = self._get_valid_value(log_val['value'])
value = log_val['value']
else:
count = 1
checked_value = self._get_valid_value(log_val)
value = log_val
assert isinstance(count,
int), ('The type of count must be int. but got '
f'{type(count): {count}}')
self.update_scalar(log_name, checked_value, count)
self.update_scalar(log_name, value, count, resumed)

def update_info(self, key: str, value: Any, resumed: bool = True) -> None:
"""Update runtime information.
Expand All @@ -208,7 +207,6 @@ def update_info(self, key: str, value: Any, resumed: bool = True) -> None:
could be resumed.
"""
self._set_resumed_keys(key, resumed)
self._resumed_keys[key] = resumed
self._runtime_info[key] = value

def update_info_dict(self, info_dict: dict, resumed: bool = True) -> None:
Expand All @@ -233,7 +231,6 @@ def update_info_dict(self, info_dict: dict, resumed: bool = True) -> None:
assert isinstance(info_dict, dict), ('`log_dict` must be a dict!, '
f'but got {type(info_dict)}')
for key, value in info_dict.items():
self._set_resumed_keys(key, resumed)
self.update_info(key, value, resumed=resumed)

def _set_resumed_keys(self, key: str, resumed: bool) -> None:
Expand Down

0 comments on commit 9567c25

Please sign in to comment.