Skip to content

Commit 4aa5fb0

Browse files
add responsibleai-text package tests to build gate (#2139)
1 parent 9c5940b commit 4aa5fb0

File tree

3 files changed

+159
-0
lines changed

3 files changed

+159
-0
lines changed
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: CI ResponsibleAI-Text pytest
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
paths:
9+
- "responsibleai_text/**"
10+
- ".github/workflows/CI-responsibleai-text-pytest.yml"
11+
12+
jobs:
13+
ci-python:
14+
strategy:
15+
matrix:
16+
packageDirectory: ["responsibleai_text"]
17+
operatingSystem: [ubuntu-latest, macos-latest, windows-latest]
18+
pythonVersion: ["3.7", "3.8", "3.9", "3.10"]
19+
# TODO: re-add macos-latest once build timeout issues are resolved
20+
exclude:
21+
- packageDirectory: "responsibleai_text"
22+
operatingSystem: macos-latest
23+
pythonVersion: "3.7"
24+
- packageDirectory: "responsibleai_text"
25+
operatingSystem: macos-latest
26+
pythonVersion: "3.8"
27+
- packageDirectory: "responsibleai_text"
28+
operatingSystem: macos-latest
29+
pythonVersion: "3.9"
30+
- packageDirectory: "responsibleai_text"
31+
operatingSystem: macos-latest
32+
pythonVersion: "3.10"
33+
runs-on: ${{ matrix.operatingSystem }}
34+
35+
steps:
36+
- uses: actions/checkout@v3
37+
38+
- uses: conda-incubator/setup-miniconda@v2
39+
with:
40+
auto-update-conda: true
41+
python-version: ${{ matrix.pythonVersion }}
42+
43+
- if: ${{ matrix.operatingSystem != 'macos-latest' }}
44+
name: Install pytorch on non-MacOS
45+
shell: bash -l {0}
46+
run: |
47+
conda install --yes --quiet pytorch torchvision captum cpuonly -c pytorch
48+
49+
- if: ${{ matrix.operatingSystem == 'macos-latest' }}
50+
name: Install Anaconda packages on MacOS, which should not include cpuonly according to official docs
51+
shell: bash -l {0}
52+
run: |
53+
conda install --yes --quiet pytorch torchvision captum -c pytorch
54+
55+
- name: Setup tools
56+
shell: bash -l {0}
57+
run: |
58+
python -m pip install --upgrade pip
59+
pip install --upgrade setuptools
60+
pip install --upgrade "pip-tools<=6.13.0"
61+
62+
- name: Install dependencies
63+
shell: bash -l {0}
64+
run: |
65+
pip install -r requirements-dev.txt
66+
pip install .
67+
working-directory: ${{ matrix.packageDirectory }}
68+
69+
- name: Setup spacy
70+
shell: bash -l {0}
71+
run: |
72+
python -m spacy download en_core_web_sm
73+
74+
- name: Install package
75+
shell: bash -l {0}
76+
run: |
77+
pip install -v -e .
78+
working-directory: ${{ matrix.packageDirectory }}
79+
80+
- name: Run tests
81+
shell: bash -l {0}
82+
run: |
83+
pytest -s -v --durations=10 --doctest-modules --junitxml=junit/test-results.xml --cov=${{ matrix.packageDirectory }} --cov-report=xml --cov-report=html
84+
working-directory: ${{ matrix.packageDirectory }}
85+
86+
- name: Upload code coverage results
87+
uses: actions/upload-artifact@v3
88+
with:
89+
name: ${{ matrix.packageDirectory }}-code-coverage-results
90+
path: ${{ matrix.packageDirectory }}/htmlcov
91+
# Use always() to always run this step to publish test results when there are test failures
92+
if: ${{ always() }}
93+
94+
- if: ${{ (matrix.operatingSystem == 'windows-latest') && (matrix.pythonVersion == '3.8') }}
95+
name: Upload to codecov
96+
id: codecovupload1
97+
uses: codecov/codecov-action@v3
98+
with:
99+
token: ${{ secrets.CODECOV_TOKEN }}
100+
directory: ${{ matrix.packageDirectory }}
101+
env_vars: OS,PYTHON
102+
fail_ci_if_error: false
103+
files: ./${{ matrix.packageDirectory }}/coverage.xml
104+
flags: unittests
105+
name: codecov-umbrella
106+
verbose: true
107+
108+
- if: ${{ (steps.codecovupload1.outcome == 'failure') && (matrix.pythonVersion == '3.8') && (matrix.operatingSystem == 'windows-latest') }}
109+
name: Retry upload to codecov
110+
id: codecovupload2
111+
uses: codecov/codecov-action@v3
112+
with:
113+
token: ${{ secrets.CODECOV_TOKEN }}
114+
directory: ${{ matrix.packageDirectory }}
115+
env_vars: OS,PYTHON
116+
fail_ci_if_error: false
117+
files: ./${{ matrix.packageDirectory }}/coverage.xml
118+
flags: unittests
119+
name: codecov-umbrella
120+
verbose: true
121+
122+
- name: Set codecov status
123+
if: ${{ (matrix.pythonVersion == '3.8') && (matrix.operatingSystem == 'windows-latest') }}
124+
shell: bash
125+
run: |
126+
if ${{ (steps.codecovupload1.outcome == 'success') || (steps.codecovupload2.outcome == 'success') }} ; then
127+
echo fine
128+
else
129+
exit 1
130+
fi

responsibleai_text/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Responsible AI Text SDK for Python
2+
3+
### This package has been tested with Python 3.6, 3.7, 3.8 and 3.9
4+
5+
The Responsible AI Text sdk enables users to analyze their machine learning models for text data in one API. Users will be able to analyze errors, explain the most important features, and understand their data using a single API.
6+
7+
Highlights of the package include:
8+
9+
- `explainer.add()` explains the model
10+
11+
### Supported scenarios, models and datasets
12+
13+
The Responsible AI Text SDK supports multiclass classification and question answering models on text data currently.
14+
15+
The open source code for the visualization dashboard can be found here:
16+
https://github.com/microsoft/responsible-ai-toolbox
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pytest==7.0.1
2+
pytest-cov
3+
pytest-mock==3.6.1
4+
5+
requirements-parser==0.2.0
6+
7+
transformers
8+
datasets
9+
tensorflow<2.11.0
10+
opencv-python
11+
12+
fastai
13+
mlflow

0 commit comments

Comments
 (0)