autolab / Tango

Standalone RESTful autograding service
http://www.autolabproject.com/
Apache License 2.0
48 stars 60 forks source link

clients/tango-cli.py can't be run without throwing exceptions #213

Closed arranstewart closed 2 years ago

arranstewart commented 3 years ago

Expected Behavior

It should be possible to run clients/tango-cli.py.

Actual Behavior

It's not possible to run clients/tango-cli.py.

As far as I can tell, it will always raise an exception:

Traceback (most recent call last):
  File "./tango-cli.py", line 69, in <module>
    help="Tango server endpoint (default = http://localhost)",
  File "/usr/lib/python3.6/argparse.py", line 1361, in add_argument
    return self._add_action(action)
  File "/usr/lib/python3.6/argparse.py", line 1724, in _add_action
    self._optionals._add_action(action)
  File "/usr/lib/python3.6/argparse.py", line 1565, in _add_action
    action = super(_ArgumentGroup, self)._add_action(action)
  File "/usr/lib/python3.6/argparse.py", line 1375, in _add_action
    self._check_conflict(action)
  File "/usr/lib/python3.6/argparse.py", line 1514, in _check_conflict
    conflict_handler(action, confl_optionals)
  File "/usr/lib/python3.6/argparse.py", line 1523, in _handle_conflict_error
    raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument -s/--server: conflicting option strings: -s, --server

Steps to Reproduce the Behavior

Run clients/tango-cli.py.

e.g. cd clients && python3 tango-cli.py.

Some suggestions

Correct me if I'm wrong, but didn't commit 49b1cf7784dd0d3e6fa816d98f8a0147b3d18e6a render tango-cli.py incapable of ever being run without exception? From the commit comments, I take it the commit was supposed to make purely cosmetic changes, but instead, it duplicates the following blocks of code in tango-cli.py:

Lines 24-36:

parser.add_argument(
    "-s",
    "--server",
    default="localhost",
    help="Tango server endpoint (default = localhost)",
)
parser.add_argument(
    "-P",
    "--port",
    default=3000,
    type=int,
    help="Tango server port number (default = 3000)",
)

Lines 65-77:

parser.add_argument(
    "-s",
    "--server",
    default="localhost",
    help="Tango server endpoint (default = http://localhost)",
)
parser.add_argument(
    "-P",
    "--port",
    default=3000,
    type=int,
    help="Tango server port number (default = 3000)",
)

Having both of these will ensure that argparse always throws an exception; I assume the first occurrence should not have been added.

A test case that simply runs tango-cli.py --help and checks that it exits without error would pick up the current issue.

arranstewart commented 3 years ago

Actually, it looks like a bigger hunk of code is duplicated - from about line 24 to about line 64 seems to duplicate later code. (Or vice versa.)

ashleyzhang commented 3 years ago

Thanks for bringing this up! We're looking into the issue now and will keep you updated.