提交 10643b4e 编写于 作者: G Ghost Under Moon 提交者: Jiabin Yang

fix- raise io error when user load from non-existed dir test=develop (#19384)

This PR fix problem with issue #18096 , which raise an error for user to specify the error about load dir is wrong
上级 c2e5eaa2
......@@ -174,6 +174,9 @@ def _save_var_to_file(stat_dict, optimizers, file_dir, file_name):
def _load_var_from_file(file_dir):
if not os.path.exists(file_dir):
raise IOError("{} not exist".format(file_dir))
def walk_filename(file_dir):
base_path = os.path.join(file_dir)
var_name_list = []
......
......@@ -150,6 +150,10 @@ class TestDygraphCheckpoint(unittest.TestCase):
dy_param_init_value[param.name] = param.numpy()
restore, _ = fluid.dygraph.load_persistables("save_dir")
self.assertRaises(IOError, fluid.dygraph.load_persistables,
"not_exist_dir")
mnist.load_dict(restore)
self.assertEqual(len(dy_param_init_value), len(restore))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册