-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtest_odh_dependencies.py
More file actions
48 lines (38 loc) · 2.13 KB
/
test_odh_dependencies.py
File metadata and controls
48 lines (38 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import urllib.request
from dparse import parse, filetypes
DEFAULT_PIPFILE = "https://raw.githubusercontent.com/opendatahub-io/notebooks/main/jupyter/datascience/ubi9-python-3.9/Pipfile"
INPUT_PIPFILE = os.getenv("INPUT_PIPFILE", DEFAULT_PIPFILE)
def test_odh_dependencies():
'''Tests whether TrustyAI's dependencies are compatible with ODH workbench-image's https://github.com/opendatahub-io/notebooks/tree/main/jupyter/datascience/ubi9-python-3.9'''
# download the pipfile
urllib.request.urlretrieve(INPUT_PIPFILE, "/tmp/Pipfile")
with open('./requirements.txt', 'r') as file:
reqtxt = parse(file.read(), file_type=filetypes.requirements_txt)
with open('./requirements-dev.txt', 'r') as file:
reqdevtxt = parse(file.read(), file_type=filetypes.requirements_txt)
with open('/tmp/Pipfile', 'r') as file:
pipfile = parse(file.read(), file_type=filetypes.pipfile)
reqtxt_names = {dependency.name: dependency for dependency in reqtxt.dependencies}
reqdevtxt_names = {dependency.name: dependency for dependency in reqdevtxt.dependencies}
mismatched_specs = []
for dependency in pipfile.dependencies:
if dependency.name in reqtxt_names.keys():
print(f"{dependency} found")
trusty_specs = reqtxt_names[dependency.name].specs
if dependency.specs == trusty_specs:
print(f"\tSpecs match ({dependency.specs})")
else:
print(
f"\tSpecs do not match ({dependency.specs} ODH vs. {reqtxt_names[dependency.name].specs} TrustyAI)")
mismatched_specs.append(dependency)
if dependency.name in reqdevtxt_names.keys():
print(f"{dependency} found")
trusty_specs = reqdevtxt_names[dependency.name].specs
if dependency.specs == trusty_specs:
print(f"\tSpecs match ({dependency.specs})")
else:
print(
f"\tSpecs do not match ({dependency.specs} ODH vs. {reqtxt_names[dependency.name].specs} TrustyAI)")
mismatched_specs.append(dependency)
assert len(mismatched_specs) == 0