diff --git a/.github/actions/dependencies/action.yml b/.github/actions/dependencies/action.yml new file mode 100644 index 0000000..304904a --- /dev/null +++ b/.github/actions/dependencies/action.yml @@ -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 diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index c238517..e73ac88 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -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 @@ -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") diff --git a/pyproject.toml b/pyproject.toml index 5b14575..3f4ed99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..9f539ed --- /dev/null +++ b/requirements-dev.txt @@ -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 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 80eedf6..d3415e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 \ No newline at end of file +matplotlib~=3.6.3 +pandas~=1.5.3 +numpy~=1.24.1 +jupyter-bokeh~=3.0.5 \ No newline at end of file diff --git a/tests/dependencies/test_odh_dependencies.py b/tests/dependencies/test_odh_dependencies.py new file mode 100644 index 0000000..0ce6cd8 --- /dev/null +++ b/tests/dependencies/test_odh_dependencies.py @@ -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''' + # 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