Skip to content

Commit

Permalink
Adding a top-level runtime python dependency checker. Goal is to
Browse files Browse the repository at this point in the history
provide a kinder error message in the case where python dependencies
are not available locally. This is motivated for future execution by
users who are running from rocm-based binary packaging instead of using
normal cmake build system which would have verified the dependencies.

Signed-off-by: Karl W. Schulz <[email protected]>
  • Loading branch information
koomie authored and coleramos425 committed May 3, 2024
1 parent 80c93aa commit d1ee2ec
Showing 1 changed file with 58 additions and 3 deletions.
61 changes: 58 additions & 3 deletions src/omniperf
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,67 @@
# SOFTWARE.
##############################################################################el

import sys
import logging
from omniperf_base import Omniperf
from utils.utils import console_error
import os
import sys
import pkg_resources
from pathlib import Path
from pkg_resources import DistributionNotFound, VersionConflict
from distutils import text_file

try:
from omniperf_base import Omniperf
from utils.utils import console_error
except:
pass


def verify_deps():

bindir = Path(__file__).resolve().parent
depsLocation = ["requirements.txt", "../requirements.txt"]

for location in depsLocation:
checkFile = os.path.join(bindir, location)
if os.path.exists(checkFile):

dependencies = text_file.TextFile(checkFile).readlines()
error = False

try:
pkg_resources.require(dependencies)
except DistributionNotFound as e:
print(
"[ERROR] The '%s' distribution was not found in the current execution environment."
% e.req.key
)
error = True

except VersionConflict as e:
print(
"[ERROR] the '%s' distribution does not meet version requirements to use omniperf."
% e.req.key
)
print(" --> version installed :", e.dist)
print(" --> version required :", e.req)
error = True

if error:
print("")
print(
"Please verify all of the python dependencies called out in the requirements file"
)
print("are installed locally prior to running omniperf.")
print("")
print("See: %s" % checkFile)
sys.exit(1)
return

def main():

# verify required python dependencies
verify_deps()

omniperf = Omniperf()

mode = omniperf.get_mode()
Expand All @@ -47,5 +101,6 @@ def main():

sys.exit(0)


if __name__ == "__main__":
main()

0 comments on commit d1ee2ec

Please sign in to comment.