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.
|
||||
"""
|
||||
if meta is None:
|
||||
meta = dict(epoch=self.epoch + 1, iter=self.iter)
|
||||
elif isinstance(meta, dict):
|
||||
meta.update(epoch=self.epoch + 1, iter=self.iter)
|
||||
else:
|
||||
meta = {}
|
||||
elif not isinstance(meta, dict):
|
||||
raise TypeError(
|
||||
f'meta should be a dict or None, but got {type(meta)}')
|
||||
if self.meta is not None:
|
||||
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)
|
||||
filepath = osp.join(out_dir, filename)
|
||||
|
|
|
@ -195,14 +195,17 @@ class IterBasedRunner(BaseRunner):
|
|||
latest checkpoint file. Defaults to True.
|
||||
"""
|
||||
if meta is None:
|
||||
meta = dict(iter=self.iter + 1, epoch=self.epoch + 1)
|
||||
elif isinstance(meta, dict):
|
||||
meta.update(iter=self.iter + 1, epoch=self.epoch + 1)
|
||||
else:
|
||||
meta = {}
|
||||
elif not isinstance(meta, dict):
|
||||
raise TypeError(
|
||||
f'meta should be a dict or None, but got {type(meta)}')
|
||||
if self.meta is not None:
|
||||
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)
|
||||
filepath = osp.join(out_dir, filename)
|
||||
|
|
Loading…
Reference in New Issue