Skip to content

FAI-978: Add ODH notebook image dependencies test to CI #145

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions .github/actions/dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Test dependencies match
description: Test if TrustyAI dependencies match ODH workbench images
inputs:
pipfile:
description: 'Location of the reference Pipfile'
required: true
runs:
using: "composite"
steps:
- name: Test against ODH dependencies
shell: bash
env:
INPUT_PIPFILE: ${{ inputs.pipfile }}
run: |
pytest -v -s tests/dependencies/test_odh_dependencies.py
7 changes: 7 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Tests

on: [ push, pull_request ]

env:
PIPFILE: ${{ vars.ODH_PIPFILE || 'https://raw.githubusercontent.com/opendatahub-io/notebooks/main/jupyter/datascience/ubi9-python-3.9/Pipfile' }}

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -34,6 +37,10 @@ jobs:
run: |
pytest -v -s tests/general
pytest -v -s tests/initialization --forked
- name: Test ODH dependencies
uses: ./.github/actions/dependencies
with:
pipfile: ${{ env.PIPFILE }}
- name: Style
run: |
black --check $(find src/trustyai -type f -name "*.py")
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ dev = [
"setuptools",
"twine==3.4.2",
"wheel~=0.38.4",
"xgboost==1.4.2"
"xgboost==1.4.2",
"dparse==0.6.2"
]

[project.urls]
Expand Down
17 changes: 17 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
JPype1==1.4.1
black~=22.12.0
click==8.0.4
joblib~=1.2.0
jupyterlab~=3.5.3
numpydoc==1.5.0
pyarrow==7.0.0
pylint==2.15.6
pytest~=7.2.1
pytest-benchmark==4.0.0
pytest-forked~=1.6.0
scikit-learn~=1.2.1
setuptools
twine==3.4.2
wheel~=0.38.4
xgboost==1.4.2
dparse==0.6.2
9 changes: 5 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
JPype1==1.4.1
matplotlib==3.5.1
pandas==1.2.5
Jpype1==1.4.1
pyarrow==7.0.0
bokeh==2.4.3
matplotlib~=3.6.3
pandas~=1.5.3
numpy~=1.24.1
jupyter-bokeh~=3.0.5
48 changes: 48 additions & 0 deletions tests/dependencies/test_odh_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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'''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to print the current INPUT_PIPFILE value or the test description must be a constant?

# 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