Skip to content

Commit cea348c

Browse files
committed
python: initial TOML support for perfflow config
- update docs - add test for toml config - use verbose mode for running tests - use python3 in user's path for unit tests
1 parent 8f3f0ca commit cea348c

File tree

12 files changed

+79
-10
lines changed

12 files changed

+79
-10
lines changed

.github/workflows/github-actions.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,5 @@ jobs:
8585
- name: Run Python Smoke Tests
8686
run: |
8787
cd src/python/test
88-
./t0001-pybinding-basic.t
88+
python -m pip list
89+
./t0001-pybinding-basic.t --verbose

docs/QuickStart.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,39 @@ Details on these can be found at the links below:
6363

6464
- **Chrome Tracing Tool:** https://www.chromium.org/developers/how-tos/trace-event-profiling-tool/
6565
- **Perfetto Visualizer:** https://perfetto.dev/
66+
67+
Users are able to customize PerfFlowAspect at runtime by changing the following
68+
environment variable: ``export PERFFLOW_OPTIONS=``. Combining options are in
69+
the colon (:) delimited form:``<parameter>=<value>:<parameter>=<value>...``
70+
71+
====================== =============== =================================================
72+
parameter default value supported metadata
73+
====================== =============== =================================================
74+
name generic
75+
log-filename-include hostname,pid | name: workflow component name
76+
| instance-path: hierarchical component path
77+
| hostname: name of host where process is running
78+
| pid: process ID
79+
log-dir ./
80+
====================== =============== =================================================
81+
82+
Alternatively, PerfFlowOptions can be specified in a TOML config file.
83+
84+
Create a TOML file named ``perfflowaspect_config.toml`` and paste the following content into the file:
85+
86+
.. code-block:: toml
87+
88+
title = "PerfFlowAspect TOML Config"
89+
90+
[perfflow-options]
91+
log-dir = "output-dir"
92+
log-filename-include = "name,hostname,pid"
93+
name = "helloworld"
94+
95+
Running the test example can be done as follows:
96+
97+
.. code:: bash
98+
99+
PERFFLOW_TOML_FILE="perfflowaspect_config.toml" ./smoketest.py
100+
101+
This will create a directory called ``output-dir`` where all PerfFlowAspect output files (``*.pfw``) will be located. The PerfFlowAspect output files will be in the form of ``perfflow.helloworld.<hostname>.<pid>.pfw``.

src/python/perfflowaspect/advice_chrome.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import logging
1919
import functools
2020
import hashlib
21+
import toml
2122
from urllib.parse import urlparse
2223
from .aspect_base import perfflowaspect
2324

@@ -40,10 +41,32 @@ def cannonicalize_perfflow_options():
4041
perfflow_options["log-dir"] = "./"
4142

4243

44+
def load_perfflow_toml_config(toml_config):
45+
config = toml.load(toml_config)
46+
print("Loaded specification -- %s\n" % toml_config)
47+
48+
perfflow_opts = None
49+
count = 0
50+
51+
for k,v in config["perfflow-options"].items():
52+
if not perfflow_opts:
53+
perfflow_opts = k + "=" + v
54+
perfflow_opts += ":" + k + "=" + v
55+
os.environ["PERFFLOW_OPTIONS"] = perfflow_opts
56+
57+
4358
def parse_perfflow_options():
4459
options_list = []
4560
options = os.getenv("PERFFLOW_OPTIONS")
46-
if options is not None:
61+
62+
toml_config = os.getenv("PERFFLOW_TOML_FILE")
63+
64+
# set PERFFLOW_OPTIONS from TOML config file
65+
if options is None and toml_config:
66+
load_perfflow_toml_config(toml_config)
67+
options = os.getenv("PERFFLOW_OPTIONS")
68+
69+
if options:
4770
options_list = options.split(":")
4871
for opt in options_list:
4972
kv = opt.split("=")
@@ -52,6 +75,9 @@ def parse_perfflow_options():
5275
else:
5376
print("Ill-formed option: {}".format(opt), file=sys.stderr)
5477
cannonicalize_perfflow_options()
78+
print("PerfFlow Config:")
79+
for k, v in perfflow_options.items():
80+
print(" ", k, "=", v)
5581

5682

5783
def get_foreign_wm():

src/python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def load_readme():
3434
author_email="ahn1@llnl.gov, herbein1@llnl.gov, corbett8@llnl.gov, dinatale3@llnl.gov",
3535
packages=["perfflowaspect"],
3636
entry_points={},
37-
install_requires=[],
37+
install_requires=["toml"],
3838
extras_require={},
3939
long_description=load_readme(),
4040
long_description_content_type="text/markdown",

src/python/test/smoketest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/python3
1+
#!/usr/bin/env python3
22

33
import time
44
import perfflowaspect

src/python/test/smoketest_MT.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/python3
1+
#!/usr/bin/env python3
22

33
import time
44
import threading

src/python/test/smoketest_direct.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/python3
1+
#!/usr/bin/env python3
22

33
import time
44
import os.path

src/python/test/smoketest_future.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env python3
22

33
import time
44
import perfflowaspect

src/python/test/smoketest_future2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env python3
22

33
import time
44
import perfflowaspect

src/python/test/smoketest_future_direct.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env python3
22

33
import os.path
44
import time

0 commit comments

Comments
 (0)