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
padding_in_crf
Ghost Under Moon 6 years ago committed by Jiabin Yang
parent c2e5eaa27d
commit 10643b4ea6

@ -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))

Loading…
Cancel
Save