d1ee2ec870
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 <karl.schulz@amd.com>
107 řádky
3.4 KiB
Python
Spustitelný soubor
107 řádky
3.4 KiB
Python
Spustitelný soubor
#!/usr/bin/env python3
|
|
|
|
##############################################################################bl
|
|
# MIT License
|
|
#
|
|
# Copyright (c) 2021 - 2024 Advanced Micro Devices, Inc. All Rights Reserved.
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
# in the Software without restriction, including without limitation the rights
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
# copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
# SOFTWARE.
|
|
##############################################################################el
|
|
|
|
import logging
|
|
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()
|
|
|
|
# major omniperf execution modes
|
|
if mode == "profile":
|
|
omniperf.run_profiler()
|
|
elif mode == "database":
|
|
omniperf.update_db()
|
|
elif mode == "analyze":
|
|
omniperf.run_analysis()
|
|
else:
|
|
console_error("Unsupported execution mode")
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|