Skip to content

Commit

Permalink
python: update pfw filename with .object or .array
Browse files Browse the repository at this point in the history
- add unit test to output object pfw file
- update expected pfw filenames in unit tests
  • Loading branch information
slabasan committed Apr 16, 2024
1 parent ce15adb commit 55d9fa0
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 75 deletions.
21 changes: 11 additions & 10 deletions src/python/perfflowaspect/advice_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ class ChromeTracingAdvice:
set_perfflow_instance_path(inst_path)

fn = "perfflow"

log_format = perfflow_options["log-format"]
if log_format in ["Array", "array", "ARRAY"]:
array_format = True
fn += ".array"
elif log_format in ["Object", "object", "OBJECT"]:
array_format = False
fn += ".object"
else:
raise ValueError("perfflow invalid option: log-format=[Array|Object]")

for inc in perfflow_options["log-filename-include"].split(","):
if inc == "name":
fn += "." + perfflow_options["name"]
Expand All @@ -163,16 +174,6 @@ class ChromeTracingAdvice:
"perfflow warning: unknown option param={}".format(inc), file=sys.stderr
)

log_format = perfflow_options["log-format"]
if log_format in ["Array", "array", "ARRAY"]:
array_format = True
fn += "-ARRAY"
elif log_format in ["Object", "object", "OBJECT"]:
array_format = False
fn += "-OBJECT"
else:
raise ValueError("perfflow invalid option: log-format=[Array|Object]")

fn += ".pfw"

log_dir = perfflow_options["log-dir"]
Expand Down
136 changes: 71 additions & 65 deletions src/python/test/t0001-pybinding-basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,187 +45,193 @@ test_expect_success 'py binding: smoketest runs ok in default' '
'

test_expect_success 'py binding: ctf file appears good' '
sanity_check perfflow.$(hostname).[0-9]*.pfw &&
rm perfflow.$(hostname).[0-9]*.pfw
sanity_check perfflow.array.$(hostname).[0-9]*.pfw &&
rm perfflow.array.$(hostname).[0-9]*.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: log-dir works' '
PERFFLOW_OPTIONS="log-dir=./logdir" ../smoketest.py &&
sanity_check ./logdir/perfflow.$(hostname).[0-9]*.pfw &&
rm ./logdir/perfflow.$(hostname).[0-9]*.pfw
sanity_check ./logdir/perfflow.array.$(hostname).[0-9]*.pfw &&
rm ./logdir/perfflow.array.$(hostname).[0-9]*.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: name can be included in filename' '
PERFFLOW_OPTIONS="name=mycomponent:log-filename-include=name" \
../smoketest.py &&
test -f perfflow.mycomponent.pfw &&
sanity_check perfflow.mycomponent.pfw &&
rm perfflow.mycomponent.pfw
test -f perfflow.array.mycomponent.pfw &&
sanity_check perfflow.array.mycomponent.pfw &&
rm perfflow.array.mycomponent.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: instance-path included in filename' '
PERFFLOW_OPTIONS="log-filename-include=instance-path" ../smoketest.py &&
test -f perfflow.{[a-f0-9]*}.pfw &&
sanity_check perfflow.{[a-f0-9]*}.pfw &&
rm perfflow.{[a-f0-9]*}.pfw
test -f perfflow.array.{[a-f0-9]*}.pfw &&
sanity_check perfflow.array.{[a-f0-9]*}.pfw &&
rm perfflow.array.{[a-f0-9]*}.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: filename includes all' '
PERFFLOW_OPTIONS="log-filename-include=name,instance-path,hostname,pid" \
../smoketest.py &&
test -f perfflow.generic.{[a-f0-9]*}.$(hostname).[0-9]*.pfw &&
sanity_check perfflow.generic.{[a-f0-9]*}.$(hostname).[0-9]*.pfw &&
rm perfflow.generic.{[a-f0-9]*}.$(hostname).[0-9]*.pfw
test -f perfflow.array.generic.{[a-f0-9]*}.$(hostname).[0-9]*.pfw &&
sanity_check perfflow.array.generic.{[a-f0-9]*}.$(hostname).[0-9]*.pfw &&
rm perfflow.array.generic.{[a-f0-9]*}.$(hostname).[0-9]*.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: filename includes all in correct order' '
PERFFLOW_OPTIONS="log-filename-include=hostname,instance-path,pid,name" \
../smoketest.py &&
test -f perfflow.$(hostname).{[a-f0-9]*}.[0-9]*.generic.pfw &&
sanity_check perfflow.$(hostname).{[a-f0-9]*}.[0-9]*.generic.pfw &&
rm perfflow.$(hostname).{[a-f0-9]*}.[0-9]*.generic.pfw
test -f perfflow.array.$(hostname).{[a-f0-9]*}.[0-9]*.generic.pfw &&
sanity_check perfflow.array.$(hostname).{[a-f0-9]*}.[0-9]*.generic.pfw &&
rm perfflow.array.$(hostname).{[a-f0-9]*}.[0-9]*.generic.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: SLURM supported' '
SLURM_JOB_ID=123456 SLURM_STEP_ID=1 \
PERFFLOW_OPTIONS="log-filename-include=instance-path" ../smoketest.py &&
sha1=$(echo -n "123456.1" | sha1sum | awk "{print \$1}" | cut -c1-8) &&
test -f perfflow.{${sha1}}.pfw &&
sanity_check perfflow.{${sha1}}.pfw &&
rm perfflow.{${sha1}}.pfw
test -f perfflow.array.{${sha1}}.pfw &&
sanity_check perfflow.array.{${sha1}}.pfw &&
rm perfflow.array.{${sha1}}.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: LSF supported' '
LSB_JOBID=123456 LS_JOBPID=1 \
PERFFLOW_OPTIONS="log-filename-include=instance-path" ../smoketest.py &&
sha1=$(echo -n "123456.1" | sha1sum | awk "{print \$1}" | cut -c1-8) &&
test -f perfflow.{${sha1}}.pfw &&
sanity_check perfflow.{${sha1}}.pfw &&
rm perfflow.{${sha1}}.pfw
test -f perfflow.array.{${sha1}}.pfw &&
sanity_check perfflow.array.{${sha1}}.pfw &&
rm perfflow.array.{${sha1}}.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: SLURM_JOB_ID + STEP_ID must be given' '
SLURM_JOB_ID=123456 \
PERFFLOW_OPTIONS="log-filename-include=instance-path" ../smoketest.py &&
sha1=$(echo -n "1" | sha1sum | awk "{print \$1}" | cut -c1-8) &&
test -f perfflow.{${sha1}}.pfw &&
sanity_check perfflow.{${sha1}}.pfw &&
rm perfflow.{${sha1}}.pfw
test -f perfflow.array.{${sha1}}.pfw &&
sanity_check perfflow.array.{${sha1}}.pfw &&
rm perfflow.array.{${sha1}}.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: LSB_JOBID + LS_JOBPID must be given' '
LSB_JOB_ID=123456 \
PERFFLOW_OPTIONS="log-filename-include=instance-path" ../smoketest.py &&
sha1=$(echo -n "1" | sha1sum | awk "{print \$1}" | cut -c1-8) &&
test -f perfflow.{${sha1}}.pfw &&
sanity_check perfflow.{${sha1}}.pfw &&
rm perfflow.{${sha1}}.pfw
test -f perfflow.array.{${sha1}}.pfw &&
sanity_check perfflow.array.{${sha1}}.pfw &&
rm perfflow.array.{${sha1}}.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: Flux supported' '
FLUX_JOB_ID=123456 \
PERFFLOW_OPTIONS="log-filename-include=instance-path" ../smoketest.py &&
test -f perfflow.{123456}.pfw &&
sanity_check perfflow.{123456}.pfw &&
rm perfflow.{123456}.pfw
test -f perfflow.array.{123456}.pfw &&
sanity_check perfflow.array.{123456}.pfw &&
rm perfflow.array.{123456}.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: Flux f58-encoded jobid supported' '
FLUX_JOB_ID=ƒeF9QZG3 \
PERFFLOW_OPTIONS="log-filename-include=instance-path" ../smoketest.py &&
test -f perfflow.{ƒeF9QZG3}.pfw &&
sanity_check perfflow.{ƒeF9QZG3}.pfw &&
rm perfflow.{ƒeF9QZG3}.pfw
test -f perfflow.array.{ƒeF9QZG3}.pfw &&
sanity_check perfflow.array.{ƒeF9QZG3}.pfw &&
rm perfflow.array.{ƒeF9QZG3}.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: nested instance-path supported' '
PERFFLOW_INSTANCE_PATH=fffffff.444444 FLUX_JOB_ID=123456 \
PERFFLOW_OPTIONS="log-filename-include=instance-path" ../smoketest.py &&
test -f perfflow.{fffffff.444444.123456}.pfw &&
sanity_check perfflow.{fffffff.444444.123456}.pfw &&
rm perfflow.{fffffff.444444.123456}.pfw
test -f perfflow.array.{fffffff.444444.123456}.pfw &&
sanity_check perfflow.array.{fffffff.444444.123456}.pfw &&
rm perfflow.array.{fffffff.444444.123456}.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: disable logging smoketest' '
PERFFLOW_OPTIONS="log-enable=False" ../smoketest.py &&
! test -f perfflow.$(hostname).[0-9]*.pfw
if test -f perfflow.$(hostname).[0-9]*.pfw; then
rm perfflow.$(hostname).[0-9]*.pfw
! test -f perfflow.array.$(hostname).[0-9]*.pfw
if test -f perfflow.array.$(hostname).[0-9]*.pfw; then
rm perfflow.array.$(hostname).[0-9]*.pfw
fi
'

test_expect_success 'PERFFLOW_OPTIONS: enable logging smoketest' '
PERFFLOW_OPTIONS="log-enable=True" ../smoketest.py &&
test -f perfflow.$(hostname).[0-9]*.pfw &&
rm perfflow.$(hostname).[0-9]*.pfw
test -f perfflow.array.$(hostname).[0-9]*.pfw &&
rm perfflow.array.$(hostname).[0-9]*.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: disable logging smoketest_future' '
PERFFLOW_OPTIONS="log-enable=False" ../smoketest_future.py &&
! test -f perfflow.$(hostname).[0-9]*.pfw
if test -f perfflow.$(hostname).[0-9]*.pfw; then
rm perfflow.$(hostname).[0-9]*.pfw
! test -f perfflow.array.$(hostname).[0-9]*.pfw
if test -f perfflow.array.$(hostname).[0-9]*.pfw; then
rm perfflow.array.$(hostname).[0-9]*.pfw
fi
'

test_expect_success 'PERFFLOW_OPTIONS: disable logging smoketest_future2' '
PERFFLOW_OPTIONS="log-enable=False" ../smoketest_future2.py &&
! test -f perfflow.$(hostname).[0-9]*.pfw
if test -f perfflow.$(hostname).[0-9]*.pfw; then
rm perfflow.$(hostname).[0-9]*.pfw
! test -f perfflow.array.$(hostname).[0-9]*.pfw
if test -f perfflow.array.$(hostname).[0-9]*.pfw; then
rm perfflow.array.$(hostname).[0-9]*.pfw
fi
'

test_expect_success 'PERFFLOW_OPTIONS: disable logging smoketest_direct' '
PERFFLOW_OPTIONS="log-enable=False" ../smoketest_direct.py &&
! test -f perfflow.$(hostname).[0-9]*.pfw
if test -f perfflow.$(hostname).[0-9]*.pfw; then
rm perfflow.$(hostname).[0-9]*.pfw
! test -f perfflow.array.$(hostname).[0-9]*.pfw
if test -f perfflow.array.$(hostname).[0-9]*.pfw; then
rm perfflow.array.$(hostname).[0-9]*.pfw
fi
'

test_expect_success 'PERFFLOW_OPTIONS: disable logging smoketest_future_direct' '
PERFFLOW_OPTIONS="log-enable=False" ../smoketest_future_direct.py &&
! test -f perfflow.$(hostname).[0-9]*.pfw
if test -f perfflow.$(hostname).[0-9]*.pfw; then
rm perfflow.$(hostname).[0-9]*.pfw
! test -f perfflow.array.$(hostname).[0-9]*.pfw
if test -f perfflow.array.$(hostname).[0-9]*.pfw; then
rm perfflow.array.$(hostname).[0-9]*.pfw
fi
'

test_expect_success 'PERFFLOW_OPTIONS: use compact format smoketest' '
PERFFLOW_OPTIONS="log-event=compact" ../smoketest.py &&
sanity_check_compact ./perfflow.$(hostname).[0-9]*.pfw &&
if test -f perfflow.$(hostname).[0-9]*.pfw; then
rm perfflow.$(hostname).[0-9]*.pfw
sanity_check_compact ./perfflow.array.$(hostname).[0-9]*.pfw &&
if test -f perfflow.array.$(hostname).[0-9]*.pfw; then
rm perfflow.array.$(hostname).[0-9]*.pfw
fi
'

test_expect_success 'PERFFLOW_OPTIONS: use verbose (default) format smoketest' '
PERFFLOW_OPTIONS="log-event=verbose" ../smoketest.py &&
sanity_check ./perfflow.$(hostname).[0-9]*.pfw &&
if test -f perfflow.$(hostname).[0-9]*.pfw; then
rm perfflow.$(hostname).[0-9]*.pfw
sanity_check ./perfflow.array.$(hostname).[0-9]*.pfw &&
if test -f perfflow.array.$(hostname).[0-9]*.pfw; then
rm perfflow.array.$(hostname).[0-9]*.pfw
fi
'

test_expect_success 'PERFFLOW_OPTIONS: output object format smoketest' '
PERFFLOW_OPTIONS="log-enable=True:log-format=object" ../smoketest.py &&
test -f perfflow.object.$(hostname).[0-9]*.pfw &&
rm perfflow.object.$(hostname).[0-9]*.pfw
'

# Run cuda tests if NVIDIA GPU is present
lspci=$(lspci | grep -i nvidia 2>/dev/null)
if [ -n "${lspci}" ]; then
test_expect_success 'py binding: smoketest_cuda runs ok in default' '
../smoketest_cuda.py &&
rm perfflow.$(hostname).[0-9]*.pfw
rm perfflow.array.$(hostname).[0-9]*.pfw
'

test_expect_success 'PERFFLOW_OPTIONS: disable logging smoketest_cuda' '
PERFFLOW_OPTIONS="log-enable=False" ../smoketest_cuda.py &&
! test -f perfflow.$(hostname).[0-9]*.pfw &&
if test -f perfflow.$(hostname).[0-9]*.pfw; then rm perfflow.$(hostname).[0-9]*.pfw; fi
! test -f perfflow.array.$(hostname).[0-9]*.pfw &&
if test -f perfflow.array.$(hostname).[0-9]*.pfw; then rm perfflow.array.$(hostname).[0-9]*.pfw; fi
'

test_expect_success 'PERFFLOW_OPTIONS: enable logging smoketest_cuda' '
PERFFLOW_OPTIONS="log-enable=True" ../smoketest_cuda.py &&
test -f perfflow.$(hostname).[0-9]*.pfw &&
rm perfflow.$(hostname).[0-9]*.pfw
test -f perfflow.array.$(hostname).[0-9]*.pfw &&
rm perfflow.array.$(hostname).[0-9]*.pfw
'
else
say "Skipping CUDA smoketests...NVIDIA GPU not found."
Expand Down

0 comments on commit 55d9fa0

Please sign in to comment.