Skip to content

Commit 2311dfc

Browse files
Fix a bug in save_model_cli 'show'.
Change: 155217646
1 parent a827ef5 commit 2311dfc

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

tensorflow/python/tools/saved_model_cli.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,14 @@ def run(args):
504504
505505
Args:
506506
args: A namespace parsed from command line.
507+
508+
Raises:
509+
AttributeError: An error when neither --inputs nor --input_exprs is passed
510+
to run command.
507511
"""
512+
if not args.inputs and not args.input_exprs:
513+
raise AttributeError(
514+
'At least one of --inputs and --input_exprs must be required')
508515
tensor_key_feed_dict = load_inputs_from_input_arg_string(
509516
args.inputs, args.input_exprs)
510517
run_saved_model_with_feed_dict(args.dir, args.tag_set, args.signature_def,
@@ -629,8 +636,6 @@ def create_parser():
629636
def main():
630637
parser = create_parser()
631638
args = parser.parse_args()
632-
if not args.inputs and not args.input_exprs:
633-
args.error('At least one of --inputs and --input_exprs is required')
634639
args.func(args)
635640

636641

tensorflow/python/tools/saved_model_cli_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,16 @@ def testRunCommandOutputFileExistError(self):
409409
with self.assertRaises(RuntimeError):
410410
saved_model_cli.run(args)
411411

412+
def testRunCommandInputNotGivenError(self):
413+
self.parser = saved_model_cli.create_parser()
414+
base_path = test.test_src_dir_path(SAVED_MODEL_PATH)
415+
args = self.parser.parse_args([
416+
'run', '--dir', base_path, '--tag_set', 'serve', '--signature_def',
417+
'serving_default'
418+
])
419+
with self.assertRaises(AttributeError):
420+
saved_model_cli.run(args)
421+
412422
def testRunCommandWithDebuggerEnabled(self):
413423
self.parser = saved_model_cli.create_parser()
414424
base_path = test.test_src_dir_path(SAVED_MODEL_PATH)

0 commit comments

Comments
 (0)