Skip to content

Commit

Permalink
Merge pull request #1588 from buildtesters/create_buildtest_config_co…
Browse files Browse the repository at this point in the history
…mpilers_list

Move compiler listing to command 'buildtest config compilers list'
  • Loading branch information
shahzebsiddiqui authored Aug 11, 2023
2 parents a522841 + 2471a81 commit dfd0416
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 27 deletions.
7 changes: 6 additions & 1 deletion bash_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,13 @@ _buildtest ()

case "${COMP_WORDS[2+offset]}" in
compilers|co)
local opts="--help --json --yaml -h -j -y find test"
local opts="--help -h list find test"
COMPREPLY=( $( compgen -W "${opts}" -- $cur ) )

if [[ "${prev}" == "list" ]]; then
local opts="--json --yaml -j -y"
COMPREPLY=( $( compgen -W "${opts}" -- $cur ) )
fi
if [[ "${prev}" == "find" ]]; then
local opts="--detailed --file --help --modulepath --update -d -h -m -u"
COMPREPLY=( $( compgen -W "${opts}" -- $cur ) )
Expand Down
16 changes: 8 additions & 8 deletions buildtest/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,19 +1050,19 @@ def config_menu(subparsers, parent_parser):
"-i", "--invalid", action="store_true", help="Show invalid executors"
)

# buildtest config compilers
compilers.add_argument(
"-j", "--json", action="store_true", help="List compiler details in JSON format"
)
compilers.add_argument(
"-y", "--yaml", action="store_true", help="List compiler details in YAML format"
)

subparsers_compiler = compilers.add_subparsers(
description="Find new compilers and add them to detected compiler section",
dest="compilers",
metavar="",
)
compiler_list = subparsers_compiler.add_parser("list", help="List compilers")
# buildtest config compilers
compiler_list.add_argument(
"-j", "--json", action="store_true", help="List compiler details in JSON format"
)
compiler_list.add_argument(
"-y", "--yaml", action="store_true", help="List compiler details in YAML format"
)

compiler_find = subparsers_compiler.add_parser(
"find", help="Find compilers", parents=[parent_parser["file"]]
Expand Down
21 changes: 17 additions & 4 deletions buildtest/cli/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,32 @@ def compiler_cmd(args, configuration):
update=args.update,
filepath=args.file,
)
return

if args.compilers == "test":
compiler_test(configuration, args.compiler_names)
return

if args.compilers == "list":
list_compilers(
configuration=configuration, print_yaml=args.yaml, print_json=args.json
)


def list_compilers(configuration, print_yaml=None, print_json=None):
"""This method will print available compilers found in configuration file which
can be retrieved by running ``buildtest config compilers list``
Args:
configuration (buildtest.config.SiteConfiguration): An instance of SiteConfiguration class
print_yaml (bool, optional): Print output in YAML format
print_json (bool, optional): Print output in JSON format
"""
bc = BuildtestCompilers(configuration)

if args.json:
if print_json:
bc.print_json()
return

if args.yaml:
if print_yaml:
bc.print_yaml()
return

Expand Down
2 changes: 1 addition & 1 deletion buildtest/cli/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def print_config_show():
"Validate configuration file /tmp/config.yml",
)
table.add_row(
"buildtest config compilers",
"buildtest config compilers list",
"List all compilers from configuration file in flat listing",
)
table.add_row(
Expand Down
26 changes: 13 additions & 13 deletions docs/configuring_buildtest/compilers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ which includes the name of the compiler in this example we call ``builtin_gcc``
system compiler that defines C, C++ and Fortran compilers using ``cc``, ``cxx`` and
``fc``.

One can retrieve all compilers using ``buildtest config compilers``, there are few
One can retrieve all compilers using ``buildtest config compilers list``, there are few
options for this command.

.. dropdown:: ``buildtest config compilers --help``
.. dropdown:: ``buildtest config compilers list --help``

.. command-output:: buildtest config compilers --help
.. command-output:: buildtest config compilers list --help

buildtest can represent compiler output in JSON, YAML using the ``--json`` and ``--yaml``.
Shown below is an example output with these options

.. dropdown:: ``buildtest config compilers --json``
.. dropdown:: ``buildtest config compilers list --json``

.. command-output:: buildtest config compilers --json
.. command-output:: buildtest config compilers list --json

.. dropdown:: ``buildtest config compilers --yaml``
.. dropdown:: ``buildtest config compilers list --yaml``

.. command-output:: buildtest config compilers --yaml
.. command-output:: buildtest config compilers list --yaml

If you want to see a flat listing of the compilers as names you can simply run ``buildtest config compilers`` as shown below
If you want to see a flat listing of the compilers as names you can simply run ``buildtest config compilers list`` as shown below

.. command-output:: buildtest config compilers
.. command-output:: buildtest config compilers list

.. _detect_compilers:

Expand Down Expand Up @@ -117,7 +117,7 @@ the module configuration to be used to access the compiler, the ``load`` propert
The ``purge`` property is a boolean that determines whether to run **module purge** prior to loading modules when using the compiler.
If ``purge: true`` is set then we will do **module purge**.

.. dropdown:: ``buildtest config compilers``
.. dropdown:: ``buildtest config compilers find``

.. code-block:: console
:emphasize-lines: 9-24
Expand Down Expand Up @@ -154,7 +154,7 @@ by searching the modules in MODULEPATH and testing each one with a regular expre
We can see in the output buildtest is applying a regular expression with each modulefile and if there is a match, we
add the compiler instance into the appropriate compiler group.

.. dropdown:: ``buildtest config compilers --detailed``
.. dropdown:: ``buildtest config compilers find --detailed``

.. code-block:: console
:linenos:
Expand Down Expand Up @@ -279,7 +279,7 @@ Now take a look at generated compilers upon running ``buildtest config compiler
:linenos:
:emphasize-lines: 16,24
(buildtest)  ~/Documents/github/ buildtest config compilers find
buildtest config compilers find
MODULEPATH: /Users/siddiq90/projects/spack/share/spack/lmod/darwin-catalina-x86_64/Core:/usr/local/Cellar/lmod/8.6.14/modulefiles/Darwin:/usr/local/Cellar/lmod/8.6.14/modulefiles/Core
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Detect Compilers ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
gcc:
Expand Down Expand Up @@ -328,7 +328,7 @@ instead of the compiler wrappers when defining a compiler instance that uses a P

.. code-block:: console
(buildtest)  ~/gitrepos/buildtest/tests/settings/ [prgenv_support] buildtest config compilers find --detailed
buildtest config compilers find --detailed
MODULEPATH: /opt/cray/pe/perftools/21.12.0/modulefiles:/opt/cray/pe/craype-targets/default/modulefiles:/opt/cray/ari/modulefiles:/opt/cray/pe/modulefiles:/opt/cray/modulefiles:/opt/modulefiles:/global/common/software/nersc/cle7up03/modulefiles:/global/common/software/nersc/cle7up03/extra_modulefiles:/global/common/cori_cle7up03/ftg/modulefiles
Searching modules by parsing content of command: module av -t
Discovered Modules
Expand Down

0 comments on commit dfd0416

Please sign in to comment.