buildtest config compilers find --file#1420
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## devel #1420 +/- ##
==========================================
- Coverage 68.57% 1.54% -67.04%
==========================================
Files 57 51 -6
Lines 6453 6312 -141
Branches 1158 1131 -27
==========================================
- Hits 4425 97 -4328
- Misses 2026 6199 +4173
- Partials 2 16 +14
... and 50 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
buildtest/cli/__init__.py
Outdated
| compiler_find.add_argument( | ||
| "-f", | ||
| "--file", | ||
| action="store_true", | ||
| help="Wrtie configuration file to a new file", | ||
| ) |
There was a problem hiding this comment.
can you please use parent parser for defining --file option so we can potentially use this option in other subcommands.
There was a problem hiding this comment.
create it as a separate variable see
buildtest/buildtest/cli/__init__.py
Lines 226 to 229 in 869ab65
-f so rule of thumb when using parent parser only have long option for now, later we can figure out which ones have short option such as -f
buildtest/cli/__init__.py
Outdated
| # use parent parser for defining --file option | ||
| file_parser = argparse.ArgumentParser(parents=[parent_parser]) | ||
| file_parser.add_argument( | ||
| "--file", action="store_true", help="Wrtie configuration file to a new file" | ||
| ) |
There was a problem hiding this comment.
can you please define the file_parser next to
buildtest/buildtest/cli/__init__.py
Line 226 in ff6de89
self.parent_parsers as a list and then we can pass this around to each method where needed.
Have something like this
self.parent_parsers['file'] = argparse.ArgumentParser(add_help=False)
self.parent_parsers['file'].add_argument("--file", action="store_true", help="Wrtie configuration file to a new file")
Then you can add the parent parser in the following line
buildtest/buildtest/cli/__init__.py
Lines 993 to 996 in ff6de89
by doing
compiler_find = subparsers_compiler.add_parser(
"find",
help="Find compilers",
parents=[self.parent_parsers['file']]
)
Does that make sense?.
There was a problem hiding this comment.
I assume I will have the following in the get_parser function:
parent_parser = {}
parent_parser["pager"] = argparse.ArgumentParser(add_help=False)
parent_parser["pager"].add_argument(
"--pager", action="store_true", help="Enable PAGING when viewing result"
)
parent_parser["file"] = argparse.ArgumentParser(add_help=False)
parent_parser["file"].add_argument(
"--file", action="store_true", help="Wrtie configuration file to a new file"And then pass parent_parser around to each menu method where needed.
If my understanding is correct, only in compiler_find will parent = [self.parent_parsers['file']].
All others that used to have parents=[parent_parser] params will become parent = [self.parent_parsers["pager"]]?
Thank you!!
There was a problem hiding this comment.
yes except change parent_parser to self.parent_parser that way we dont need to pass variable around each method. Yes i think you understand the logic.
Depending on the subcommand you will have parents=[self.parent_parsers['pager'] where --pager option is inherited. Likewise, where --file is inherited you can do parents=[self.parent_parsers['file']]. In event multiple arguments need to be inherited to a sub-command we should be able to index the dict so parents=[self.parent_parsers['pager'], [self.parent_parsers['file']].
Also a tip when copying code in markdown you can use triple backticks to format code. If you want to format python code you can do ```python. Github supports syntax highlighting for several languages you should take a look at https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting
|
Hi @shahzebsiddiqui, running command below keeps getting unrecognized arguments error. Can you take a look? usage: buildtest [options] [COMMANDS] |
buildtest/cli/__init__.py
Outdated
|
|
||
| parent_parser["file"] = argparse.ArgumentParser(add_help=False) | ||
| parent_parser["file"].add_argument( | ||
| "--file", action="store_true", help="Wrtie configuration file to a new file" |
There was a problem hiding this comment.
yes the issue is right here i missed this, please remove action="store_true" we need argparse to hold value of the file not a true or false. This should fix the issue
see my message https://github.com/buildtesters/buildtest/pull/1420/files#r1157445437 the add_argument is not setup correctly. Let me know if this fix. the issue |
|
@Xiangs18 i saw the gitlab runner was stuck so i restarted it now your CI job is running on Perlmutter https://software.nersc.gov/NERSC/buildtest/-/jobs/202208 hopefully we will see the test coverage results in codecov. |

No description provided.