Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting tagging functionality #65

Merged
merged 62 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
00724e2
Starting tagging functionality
pearce8 Dec 1, 2023
47ab9d9
Update benchpark_tags.yaml
pearce8 Dec 5, 2023
292d44b
Merge branch 'develop' into feature/tagging
pearce8 Dec 5, 2023
ccd13e5
Update benchpark_tags.yaml
pearce8 Dec 5, 2023
08fe3b1
copyright
pearce8 Dec 18, 2023
fb938e1
Merge branch 'develop' into feature/tagging
pearce8 Dec 18, 2023
03e2f71
trying to fix lint
pearce8 Dec 19, 2023
60904ed
Merge branch 'develop' into feature/tagging
pearce8 Dec 28, 2023
87b3d50
Merge branch 'develop' into feature/tagging
pearce8 Jan 9, 2024
70b35a5
Adding tags
pearce8 Jan 9, 2024
84c3770
Adding tags
pearce8 Jan 9, 2024
d79d247
Adding tags
pearce8 Jan 9, 2024
d3d3ea5
adding tags
pearce8 Jan 9, 2024
12838a2
adding tags
pearce8 Jan 9, 2024
3a0ca27
adding tags
pearce8 Jan 9, 2024
5dcd37f
Expanding benchmark tags options
pearce8 Jan 9, 2024
41ca661
Update tags
pearce8 Jan 9, 2024
bc04a8e
Merge branch 'develop' into feature/tagging
pearce8 Jan 16, 2024
2c78ce0
Merge branch 'develop' into feature/tagging
pearce8 Jan 17, 2024
b5aa5e8
Merge branch 'develop' into feature/tagging
pearce8 Jan 20, 2024
c85a195
Merge branch 'develop' into feature/tagging
pearce8 Jan 27, 2024
7eb1496
Adding functionality to see all tags, and all experiments with a spec…
pearce8 Jan 29, 2024
4b540af
adding more options to tag queries, and adding to the docs
pearce8 Jan 29, 2024
34c6dc8
fix typo CI caught
pearce8 Jan 30, 2024
9832874
formatting
pearce8 Jan 30, 2024
f8bcd49
Merge branch 'develop' into feature/tagging
pearce8 Jan 30, 2024
2dc9362
Merge branch 'develop' into feature/tagging
pearce8 Jan 30, 2024
2129abc
formatting
pearce8 Jan 30, 2024
9619f6d
Starting table descriptions of benchmarks and tags for the docs
pearce8 Jan 30, 2024
2c06e3b
lint
pearce8 Jan 30, 2024
45f73fd
add help menu to docs
slabasan Jan 30, 2024
e299644
add new page for current benchpark help menu
slabasan Jan 31, 2024
838721d
starting benchpark list into table
slabasan Jan 31, 2024
29e033e
starting tags list into table
slabasan Jan 31, 2024
8b56a20
Merge branch 'develop' into feature/tagging
pearce8 Feb 5, 2024
1084a54
Merge branch 'develop' into feature/tagging
pearce8 Feb 6, 2024
457480d
notes
slabasan Feb 6, 2024
8d10b2d
Merge remote-tracking branch 'origin/feature/tagging' into feature/ta…
slabasan Feb 6, 2024
32a9c4a
working benchmark list table
slabasan Feb 7, 2024
22fc396
fix page reference
slabasan Feb 7, 2024
167923f
use benchmark tags command
slabasan Feb 20, 2024
9b121b0
Merging in develop
pearce8 Feb 21, 2024
3c0ac74
use benchpark tags command
slabasan Feb 22, 2024
4e89b82
remove commented out code
slabasan Feb 22, 2024
b9fceaa
remove unused parsing script for tags
slabasan Feb 22, 2024
f6555d5
black
slabasan Feb 22, 2024
4733304
remove unused import
slabasan Feb 22, 2024
01974bd
Merge branch 'develop' into feature/tagging
pearce8 Feb 22, 2024
5268517
Merge branch 'develop' into feature/tagging
pearce8 Feb 22, 2024
914f161
Merge branch 'develop' into feature/tagging
pearce8 Feb 23, 2024
fd598fb
Merge branch 'develop' into feature/tagging
pearce8 Feb 27, 2024
51318c5
Merge branch 'develop' into feature/tagging
pearce8 Feb 28, 2024
9413be1
Merge branch 'develop' into feature/tagging
slabasan Mar 13, 2024
5e3b193
Add CI setup to install ramble for use in docs generation
alecbcs Mar 13, 2024
f773524
add tag table generator script to makefile
slabasan Mar 13, 2024
e2fb13d
run all
slabasan Mar 13, 2024
0fc7013
Add yaml dependency to docs CI
alecbcs Mar 13, 2024
44dd1a8
fixes
slabasan Mar 13, 2024
77ff056
sphinxcontrib-programoutput req
slabasan Mar 13, 2024
f1f28ca
Fix codspell looking in the rendered docs
alecbcs Mar 13, 2024
1adeb7f
remove tables/*.csv
slabasan Mar 13, 2024
b06808e
run benchmark tags script
slabasan Mar 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ jobs:
- name: Install Sphinx and Theme via Pip
run: |
pip install -r .github/workflows/requirements/docs.txt
# create a dummy workspace to get a working ramble
bin/benchpark setup saxpy/openmp nosite-x86_64 /tmp/workspace
# this is gross and we should better setup ramble for people or make it a Spack package
pip install -r /tmp/workspace/ramble/requirements.txt

- name: Build with sphinx
run: |
sphinx-build docs/ _build
cd docs
make html WORKSPACE_PATH=/tmp/workspace

- name: Check for Typos using Codespell
run: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
sphinx==7.2.6
sphinx-rtd-theme==2.0.0
codespell==2.2.6
pandas==2.2.0
pyyaml==6.0.1
sphinxcontrib-programoutput==0.17
130 changes: 128 additions & 2 deletions bin/benchpark
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def main():
actions = {}
benchpark_list(subparsers, actions)
benchpark_setup(subparsers, actions)
benchpark_tags(subparsers, actions)

args = parser.parse_args()
no_args = True if len(sys.argv) == 1 else False
Expand All @@ -62,7 +63,6 @@ def main():

def get_version():
benchpark_version = __version__

return benchpark_version


Expand All @@ -89,6 +89,15 @@ def benchpark_benchmarks():
return benchmarks


def benchpark_experiments():
source_dir = source_location()
experiments = []
experiments_dir = source_dir / "experiments"
for x in os.listdir(experiments_dir):
experiments.append(f"{x}")
return experiments


def benchpark_systems():
source_dir = source_location()
systems = []
Expand All @@ -97,6 +106,28 @@ def benchpark_systems():
return systems


def benchpark_get_tags():
f = source_location() / "tags.yaml"
tags = []

with open(f, "r") as stream:
try:
data = yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)

for k0, v0 in data.items():
if k0 == "benchpark-tags":
for k, v in v0.items():
if isinstance(v, list):
for i in v:
tags.append(i)
else:
print("ERROR file does not contain benchpark-tags")

return tags


def benchpark_list_handler(args):
source_dir = source_location()
sublist = args.sublist
Expand Down Expand Up @@ -137,6 +168,17 @@ def benchpark_check_benchmark(arg_str):
return found


def benchpark_check_experiment(arg_str):
experiments = benchpark_experiments()
found = arg_str in experiments
if not found:
out_str = f'Invalid benchmark/experiment "{arg_str}" - must choose one of: '
for experiment in experiments:
out_str += f"\n\t{experiment}"
raise ValueError(out_str)
return found


def benchpark_check_system(arg_str):
systems = benchpark_systems()
found = arg_str in systems
Expand All @@ -148,6 +190,17 @@ def benchpark_check_system(arg_str):
return found


def benchpark_check_tag(arg_str):
tags = benchpark_get_tags()
found = arg_str in tags
if not found:
out_str = f'Invalid tag "{arg_str}" - must choose one of: '
for tag in tags:
out_str += f"\n\t{tag}"
raise ValueError(out_str)
return found


def benchpark_setup(subparsers, actions_dict):
create_parser = subparsers.add_parser(
"setup", help="Set up an experiment and prepare it to build/run"
Expand Down Expand Up @@ -175,7 +228,7 @@ def benchpark_setup(subparsers, actions_dict):


def run_command(command_str, env=None):
subprocess.run(
result = subprocess.run(
shlex.split(command_str),
env=env,
check=True,
Expand All @@ -184,6 +237,30 @@ def run_command(command_str, env=None):
text=True,
)

return (result.stdout, result.stderr)


def benchpark_tags(subparsers, actions_dict):
create_parser = subparsers.add_parser("tags", help="Tags in Benchpark experiments")
create_parser.add_argument(
"experiments_root",
type=str,
help="The experiments_root you specified during Benchpark setup.",
)
create_parser.add_argument(
"-a",
"--application",
action="store",
help="The application for which to find Benchpark tags",
)
create_parser.add_argument(
"-t",
"--tag",
action="store",
help="The tag for which to search in Benchpark experiments",
)
actions_dict["tags"] = benchpark_tags_handler


# Note: it would be nice to vendor spack.llnl.util.link_tree, but that
# involves pulling in most of llnl/util/ and spack/util/
Expand Down Expand Up @@ -375,5 +452,54 @@ Further steps are needed to build the experiments (ramble -P -D {ramble_workspac
print(instructions)


def helper_experiments_tags(ramble_exe, experiments):
# find all tags in Ramble applications (both in Ramble built-in and in Benchpark/repo)
(tags_stdout, tags_stderr) = run_command(f"{ramble_exe} attributes --tags --all")
ramble_applications_tags = {}
lines = tags_stdout.splitlines()

for line in lines:
key_value = line.split(":")
ramble_applications_tags[key_value[0]] = key_value[1].strip().split(",")

benchpark_experiments_tags = {}
for exp in experiments:
benchpark_experiments_tags[exp] = ramble_applications_tags[exp]
return benchpark_experiments_tags


def benchpark_tags_handler(args):
"""
Filter ramble tags by benchpark experiments
"""
source_dir = source_location()
experiments_root = pathlib.Path(os.path.abspath(args.experiments_root))
ramble_location = experiments_root / "ramble"
ramble_exe = ramble_location / "bin" / "ramble"
experiments = benchpark_experiments()

if args.tag:
if benchpark_check_tag(args.tag):
# find all applications in Ramble that have a given tag (both in Ramble built-in and in Benchpark/repo)
(tag_stdout, tag_stderr) = run_command(f"{ramble_exe} list -t {args.tag}")
lines = tag_stdout.splitlines()

for line in lines:
if line in experiments:
print(line)

elif args.application:
if benchpark_check_experiment(args.application):
benchpark_experiments_tags = helper_experiments_tags(
ramble_exe, experiments
)
print(benchpark_experiments_tags[args.application])
else:
benchpark_experiments_tags = helper_experiments_tags(ramble_exe, experiments)
print("All tags that exist in Benchpark experiments:")
for k, v in benchpark_experiments_tags.items():
print(k)


if __name__ == "__main__":
main()
41 changes: 35 additions & 6 deletions docs/2-benchpark-list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,43 @@

SPDX-License-Identifier: Apache-2.0

==============
Benchpark List
==============
================
Search Benchpark
================

To list all benchmarks and systems available in Benchpark::
The user can search for available system and experiment specifications in Benchpark.

.. list-table:: Searching for specifications in Benchpark
:widths: 25 25 50
:header-rows: 1

* - Command
- Description
- Listing in the docs
* - benchpark list
- Lists all benchmarks and systems specified in Benchpark
-
* - benchpark list systems
- Lists all system specified in Benchpark
- :doc:`available-system-specs`
* - benchmark list benchmarks
- Lists all benchmarks specified in Benchpark
-
* - benchpark list systems
- Lists all system specified in Benchpark
- :doc:`available-system-specs`
* - benchpark tags workspace
- Lists all tags specified in Benchpark
-
* - benchpark tags -a application workspace
- Lists all tags specified for a given application in Benchpark
-
* - benchpark tags -t tag workspace
- Lists all experiments in Benchpark with a given tag
-

cd bin
benchpark list

Once you have decided on a ``system`` you will use, and the ``benchmark/ProgrammingModel``
to run, you can proceed to :doc:`4-benchpark-setup`.

For a complete list of options, see the help menu in :doc:`benchpark-help`.
6 changes: 5 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
WORKSPACE_PATH ?=

# Put it first so that "make" without argument is like "make help".
help:
Expand All @@ -15,7 +16,10 @@ help:
systemconfigs:
./generate-sys-defs-list.py

.PHONY: help sysconfigs Makefile
tags:
./generate-benchmark-list.py $(WORKSPACE_PATH)

.PHONY: help systemconfigs tags Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
Expand Down
2 changes: 1 addition & 1 deletion docs/available-system-specs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ use as the ``system`` parameter in Benchpark setup. See
:doc:`4-benchpark-setup` for more details.

.. csv-table:: Current system definitions in Benchpark.
:file: tables/current-system-definitions.csv
:file: current-system-definitions.csv
:header-rows: 1
:align: left
13 changes: 13 additions & 0 deletions docs/benchmark-list.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. Copyright 2023 Lawrence Livermore National Security, LLC and other
Benchpark Project Developers. See the top-level COPYRIGHT file for details.

SPDX-License-Identifier: Apache-2.0

==============
Benchmark List
==============

.. csv-table:: Current Benchpark tags by benchmark and tag groups.
:file: benchmark-list.csv
:header-rows: 1
:align: left
14 changes: 14 additions & 0 deletions docs/benchpark-help.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. Copyright 2023 Lawrence Livermore National Security, LLC and other
Benchpark Project Developers. See the top-level COPYRIGHT file for details.

SPDX-License-Identifier: Apache-2.0

===================
Benchpark Help Menu
===================

Benchpark help menu::

$ benchpark --help

.. program-output:: ../bin/benchpark --help
8 changes: 8 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
]
)

subprocess.call(
[
"make",
"tags",
]
)

project = "Benchpark"
copyright = "2023, LLNS LLC"
author = "Olga Pearce, Alec Scott, Peter Scheibel, Greg Becker, Riyaz Haque, and Nathan Hanford"
Expand All @@ -24,6 +31,7 @@

extensions = [
"sphinx_rtd_theme",
"sphinxcontrib.programoutput",
]

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".spack-env"]
Expand Down
Loading