You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by tq...@apache.org on 2020/10/06 12:47:54 UTC

[incubator-tvm] branch master updated: [TVMC] fail gracefully in case no subcommand is provided (#6625)

This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git


The following commit(s) were added to refs/heads/master by this push:
     new 82289ea  [TVMC] fail gracefully in case no subcommand is provided (#6625)
82289ea is described below

commit 82289ea15b76e20184117a0da44d29d838e55be9
Author: Leandro Nunes <le...@gmail.com>
AuthorDate: Tue Oct 6 13:47:24 2020 +0100

    [TVMC] fail gracefully in case no subcommand is provided (#6625)
---
 python/tvm/driver/tvmc/main.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/python/tvm/driver/tvmc/main.py b/python/tvm/driver/tvmc/main.py
index 9371341..fee04db 100644
--- a/python/tvm/driver/tvmc/main.py
+++ b/python/tvm/driver/tvmc/main.py
@@ -79,7 +79,10 @@ def _main(argv):
         sys.stdout.write("%s\n" % version)
         return 0
 
-    assert hasattr(args, "func"), "Error: missing 'func' attribute for subcommand {0}".format(argv)
+    if not hasattr(args, "func"):
+        # In case no valid subcommand is provided, show usage and exit
+        parser.print_help(sys.stderr)
+        return 1
 
     try:
         return args.func(args)