Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a top-level runtime python dependency checker. #358

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Ubuntu 20.04](https://github.com/ROCm/omniperf/actions/workflows/ubuntu-focal.yml/badge.svg)](https://github.com/ROCm/omniperf/actions/workflows/ubuntu-focal.yml)
[![RHEL 8](https://github.com/ROCm/omniperf/actions/workflows/opensuse.yml/badge.svg)](https://github.com/ROCm/omniperf/actions/workflows/opensuse.yml)
[![MI100](https://github.com/ROCm/omniperf/actions/workflows/mi100.yml/badge.svg?branch=2.x)](https://github.com/ROCm/omniperf/actions/workflows/mi100.yml)
[![Ubuntu 22.04](https://github.com/ROCm/omniperf/actions/workflows/ubuntu-jammy.yml/badge.svg)](https://github.com/ROCm/omniperf/actions/workflows/ubuntu-jammy.yml)
[![RHEL 8](https://github.com/ROCm/omniperf/actions/workflows/rhel-8.yml/badge.svg)](https://github.com/ROCm/omniperf/actions/workflows/rhel-8.yml)
[![Instinct](https://github.com/ROCm/omniperf/actions/workflows/mi-rhel9.yml/badge.svg)](https://github.com/ROCm/omniperf/actions/workflows/mi-rhel9.yml)
[![Docs](https://github.com/ROCm/omniperf/actions/workflows/docs.yml/badge.svg)](https://rocm.github.io/omniperf/)
[![DOI](https://zenodo.org/badge/561919887.svg)](https://zenodo.org/badge/latestdoi/561919887)

Expand Down
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()