Skip to content

Commit

Permalink
Replacing subprocess with shutil
Browse files Browse the repository at this point in the history
Signed-off-by: coleramos425 <colramos@amd.com>
  • Loading branch information
coleramos425 committed Aug 24, 2023
1 parent b65aacf commit 7d457b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
9 changes: 4 additions & 5 deletions src/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,17 @@ def resolve_rocprof(returnPath=False):
else:
rocprof_cmd = os.environ["ROCPROF"]

rocprof_path = subprocess.run(
["which", rocprof_cmd], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
if rocprof_path.returncode != 0:
rocprof_path = shutil.which(rocprof_cmd)

if not rocprof_path:
print("\nError: Unable to resolve path to %s binary" % rocprof_cmd)
print(
"Please verify installation or set ROCPROF environment variable with full path."
)
sys.exit(1)
else:
# Resolve any sym links in file path
rocprof_path = os.path.realpath(rocprof_path.stdout.decode("utf-8").rstrip("\n"))
rocprof_path = os.path.realpath(rocprof_path.rstrip("\n"))
print("ROC Profiler: ", rocprof_path)
if returnPath:
return rocprof_path
Expand Down
19 changes: 7 additions & 12 deletions src/omniperf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import pandas as pd
from datetime import datetime
from pathlib import Path as path
import warnings
import shutil

from parser import parse
from utils import specs
Expand Down Expand Up @@ -438,10 +439,8 @@ def characterize_app(args, VER):
def run_rocscope(args, fname):
# profile the app
if args.use_rocscope == True:
result = subprocess.run(
["which", "rocscope"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
if result.returncode == 0:
result = shutil.which("rocscope")
if result:
rs_cmd = [
result.stdout.decode("ascii").strip(),
"metrics",
Expand Down Expand Up @@ -553,10 +552,8 @@ def omniperf_profile(args, VER):
print(e)
sys.exit(1)

result = subprocess.run(
["which", "rocscope"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
if result.returncode == 0:
result = shutil.which("rocscope")
if result:
rs_cmd = [
result.stdout.decode("ascii").strip(),
"top10",
Expand Down Expand Up @@ -587,10 +584,8 @@ def omniperf_profile(args, VER):
print(e)
sys.exit(1)

result = subprocess.run(
["which", "rocscope"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
if result.returncode == 0:
result = shutil.which("rocscope")
if result:
rs_cmd = [
result.stdout.decode("ascii").strip(),
"summary",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/perfagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# SOFTWARE.
##############################################################################el

import sys, os, pathlib, shutil, subprocess, argparse, glob, re
import sys, os, shutil, glob, re
import numpy as np
import math
import warnings
Expand Down

0 comments on commit 7d457b5

Please sign in to comment.