mirror of https://github.com/open-mmlab/mmcv.git
Change dict update order (#1108)
* Change dict update order * Change dict() with {} * Added comments with PR link * Fixed comments according to Lint Jobpull/1160/head
parent
1d5ee6e09a
commit
b035fe9171
|
@ -151,14 +151,17 @@ class EpochBasedRunner(BaseRunner):
|
||||||
Defaults to True.
|
Defaults to True.
|
||||||
"""
|
"""
|
||||||
if meta is None:
|
if meta is None:
|
||||||
meta = dict(epoch=self.epoch + 1, iter=self.iter)
|
meta = {}
|
||||||
elif isinstance(meta, dict):
|
elif not isinstance(meta, dict):
|
||||||
meta.update(epoch=self.epoch + 1, iter=self.iter)
|
|
||||||
else:
|
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f'meta should be a dict or None, but got {type(meta)}')
|
f'meta should be a dict or None, but got {type(meta)}')
|
||||||
if self.meta is not None:
|
if self.meta is not None:
|
||||||
meta.update(self.meta)
|
meta.update(self.meta)
|
||||||
|
# Note: meta.update(self.meta) should be done before
|
||||||
|
# meta.update(epoch=self.epoch + 1, iter=self.iter) otherwise
|
||||||
|
# there will be problems with resumed checkpoints.
|
||||||
|
# More details in https://github.com/open-mmlab/mmcv/pull/1108
|
||||||
|
meta.update(epoch=self.epoch + 1, iter=self.iter)
|
||||||
|
|
||||||
filename = filename_tmpl.format(self.epoch + 1)
|
filename = filename_tmpl.format(self.epoch + 1)
|
||||||
filepath = osp.join(out_dir, filename)
|
filepath = osp.join(out_dir, filename)
|
||||||
|
|
|
@ -195,14 +195,17 @@ class IterBasedRunner(BaseRunner):
|
||||||
latest checkpoint file. Defaults to True.
|
latest checkpoint file. Defaults to True.
|
||||||
"""
|
"""
|
||||||
if meta is None:
|
if meta is None:
|
||||||
meta = dict(iter=self.iter + 1, epoch=self.epoch + 1)
|
meta = {}
|
||||||
elif isinstance(meta, dict):
|
elif not isinstance(meta, dict):
|
||||||
meta.update(iter=self.iter + 1, epoch=self.epoch + 1)
|
|
||||||
else:
|
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
f'meta should be a dict or None, but got {type(meta)}')
|
f'meta should be a dict or None, but got {type(meta)}')
|
||||||
if self.meta is not None:
|
if self.meta is not None:
|
||||||
meta.update(self.meta)
|
meta.update(self.meta)
|
||||||
|
# Note: meta.update(self.meta) should be done before
|
||||||
|
# meta.update(epoch=self.epoch + 1, iter=self.iter) otherwise
|
||||||
|
# there will be problems with resumed checkpoints.
|
||||||
|
# More details in https://github.com/open-mmlab/mmcv/pull/1108
|
||||||
|
meta.update(epoch=self.epoch + 1, iter=self.iter)
|
||||||
|
|
||||||
filename = filename_tmpl.format(self.iter + 1)
|
filename = filename_tmpl.format(self.iter + 1)
|
||||||
filepath = osp.join(out_dir, filename)
|
filepath = osp.join(out_dir, filename)
|
||||||
|
|
Loading…
Reference in New Issue