Skip to content

fix argparser issue with option --help-all#1708

Merged
shahzebsiddiqui merged 1 commit intodevelfrom
fix_help_all_option
Feb 16, 2024
Merged

fix argparser issue with option --help-all#1708
shahzebsiddiqui merged 1 commit intodevelfrom
fix_help_all_option

Conversation

@shahzebsiddiqui
Copy link
Member

This PR will address an issue we were having when running the command

(buildtest) ☁  buildtest [fix_conflict_subparser_tutorial-examples] buildtest --help-all
Traceback (most recent call last):
  File "/Users/siddiq90/Documents/GitHubDesktop/buildtest/bin/buildtest", line 38, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/siddiq90/Documents/GitHubDesktop/buildtest/buildtest/main.py", line 73, in main
    parser = BuildTestParser()
             ^^^^^^^^^^^^^^^^^
  File "/Users/siddiq90/Documents/GitHubDesktop/buildtest/buildtest/cli/__init__.py", line 318, in __init__
    self.help_all()
  File "/Users/siddiq90/Documents/GitHubDesktop/buildtest/buildtest/cli/__init__.py", line 452, in help_all
    self.subparsers.add_parser(
  File "/usr/local/Cellar/python@3.11/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/argparse.py", line 1192, in add_parser
    raise ArgumentError(self, _('conflicting subparser: %s') % name)
argparse.ArgumentError: argument : conflicting subparser: tutorial-examples

With the new change we can see the output

(buildtest) ☁  buildtest [fix_help_all_option] buildtest --help-all
usage: buildtest [options] [COMMANDS]

buildtest is a HPC testing framework for building and running tests.

options:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -c CONFIGFILE, --configfile CONFIGFILE
                        Specify Path to Configuration File
  -d, --debug           Stream log messages to stdout
  -l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                        Filter log messages based on logging level
  --editor {vi,vim,emacs,nano}
                        Select your preferred editor when opening files.
  --view-log            Show content of last log
  --logpath             Print full path to last log file
  --print-log           Print content of last log without pagination
  --color COLOR         Print output of table with the selected color.
  --no-color            Disable colored output
  --helpcolor           Print available color options in a table format.
  -r REPORT, --report REPORT
                        Specify path to test report file
  -H, --help-all        List all commands and options

COMMANDS:
  
    build (bd)          Build and Run test
    buildspec (bc)      Buildspec Interface
    config (cg)         Query buildtest configuration
    report (rt)         Query test report
    inspect (it)        Inspect a test
    path (p)            Show path attributes for a given test
    history (hy)        Query build history
    schema              List schema contents and examples
    cdash               Upload test to CDASH server
    cd                  Change directory to root of test given a test name
    clean               Remove all generate files from buildtest including test directory, log files, report file, buildspec cache, history files
    debugreport (debug)
                        Display system information and additional information for debugging purposes.
    stats               Show test statistics for given test
    info                Show details regarding current buildtest setup
    show                buildtest command guide
    commands (cmds)     List all buildtest commands
    tutorial-examples   Generate documentation examples for Buildtest Tutorial
    docs                Open buildtest docs in browser
    unittests (test)    Run buildtest unit tests
    stylecheck (style)  Run buildtest style checks

    References

    GitHub:                  https://github.com/buildtesters/buildtest
    Documentation:           https://buildtest.readthedocs.io/en/latest/index.html
    Slack:                   http://hpcbuildtest.slack.com/

    Please report issues at https://github.com/buildtesters/buildtest/issues

    Copyright (c) 2021-2024, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy), Shahzeb Siddiqui, and Vanessa Sochat. All rights reserved.

…-all' due to name conflict.

We have fixed this now and command options are working.
Created a method in BuildTestParser called get_subcommands which will retrieve a list of subcommands that can be
used by 'buildtest commands' to show list of commands
@shahzebsiddiqui shahzebsiddiqui merged commit 7254fab into devel Feb 16, 2024
@shahzebsiddiqui shahzebsiddiqui deleted the fix_help_all_option branch February 16, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant