Skip to content

Commit

Permalink
fix nightly build failures (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
imatiach-msft authored Dec 4, 2021
1 parent ffe9931 commit 7629b78
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
3 changes: 1 addition & 2 deletions azuredevops/templates/all-tests-job-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jobs:
- ${{ each pyVer in parameters.pyVersions }}:
- job:
displayName: ${{ format('{0} {1} {2}', plat.Key , testRunType, pyVer) }}
${{ if eq(plat.Key, 'Windows')}}:
timeoutInMinutes: 240
timeoutInMinutes: 360
pool:
vmImage: ${{ plat.value }}

Expand Down
6 changes: 3 additions & 3 deletions azuredevops/templates/test-run-step-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ steps:
- ${{ if eq(parameters.testRunType, 'Unit')}}:
- bash: |
source activate ${{parameters.condaEnv}}
python -m pytest test/unit --junitxml=./TEST--TEST.xml -o junit_suite_name="$(Agent.JobName)-Unit"
python -m pytest -s -v test/unit --junitxml=./TEST--TEST.xml -o junit_suite_name="$(Agent.JobName)-Unit"
displayName: Run Unit tests
- ${{ if eq(parameters.testRunType, 'Integration')}}:
- bash: |
source activate ${{parameters.condaEnv}}
python -m pytest test/integration/ --junitxml=./TEST--TEST.xml -o junit_suite_name="$(Agent.JobName)-Integration"
python -m pytest -s -v test/integration/ --junitxml=./TEST--TEST.xml -o junit_suite_name="$(Agent.JobName)-Integration"
displayName: Run Integration tests
- ${{ if eq(parameters.testRunType, 'CodeCoverage')}}:
- bash: |
source activate ${{parameters.condaEnv}}
python -m pytest test/unit --junitxml=./TEST--TEST.xml -o junit_suite_name="$(Agent.JobName)-Coverage" --cov=python --cov-report=xml --cov-report=html -o unit_suite_name="UnitCoverage"
python -m pytest -s -v test/unit --junitxml=./TEST--TEST.xml -o junit_suite_name="$(Agent.JobName)-Coverage" --cov=python --cov-report=xml --cov-report=html -o unit_suite_name="UnitCoverage"
displayName: Run Code Coverage tests
- task: PublishCodeCoverageResults@1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"outputs": [],
"source": [
"# Create explainer object that contains default glassbox classifier and explanation methods\n",
"explainer = ClassicalTextExplainer()\n",
"explainer = ClassicalTextExplainer(n_jobs=-1, tol=0.1)\n",
"label_encoder = LabelEncoder()"
]
},
Expand Down
16 changes: 13 additions & 3 deletions python/interpret_text/experimental/classical.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class ClassicalTextExplainer:
"""

def __init__(self, preprocessor=None, model=None,
hyperparam_range=None, is_trained=False):
hyperparam_range=None, is_trained=False,
n_jobs=None, tol=0.0001):
"""Initialize the ClassicalTextExplainer
:param model: Linear models with linear coefs mapped to features or
tree based models with inbuilt feature_importances that are sklearn
Expand All @@ -52,7 +53,13 @@ def __init__(self, preprocessor=None, model=None,
:param hyperparam_range: Custom hyper parameter range to search over
when training input model. passed to sklearn's GridsearchCV's
as param_grid argument.
:type hyperparam_range: dict """
:type hyperparam_range: dict
:param n_jobs: The number of jobs to run in parallel.
Passed to GridSearchCV. -1 means using all processors.
:type n_jobs: int
:param tol: Tolerance for stopping criteria. Default is 1e-4.
:type tol: float
"""
self.parsed_sentence = None
self.word_importances = None
self.model = model
Expand All @@ -69,6 +76,8 @@ def __init__(self, preprocessor=None, model=None,
"Custom model needs to be supplied with custom hyperparameter range to search over."
)
self.preprocessor = BOWEncoder() if preprocessor is None else preprocessor
self.n_jobs = n_jobs
self.tol = tol

def _encode(self, X_str):
"""Encode text strings in X_str as vectors.
Expand Down Expand Up @@ -114,8 +123,9 @@ def fit(self, X_str, y_train):
self.model = LogisticRegression()
# Hyperparameters were chosen through hyperparamter optimization on MNLI
self.hyperparam_range = [ExplainerParams.HYPERPARAM_RANGE]
self.hyperparam_range[0]['tol'] = [self.tol]
classifier_CV = GridSearchCV(
self.model, self.hyperparam_range, cv=3, scoring="accuracy"
self.model, self.hyperparam_range, cv=3, scoring="accuracy", n_jobs=self.n_jobs
)
classifier_CV.fit(X_train, y_train)
# set model as the best estimator from grid search results
Expand Down
6 changes: 3 additions & 3 deletions tools/generate_conda_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
PIP_BASE = {
"interpret-community": "interpret-community>=0.16.0",
"cached-property": "cached-property==1.5.1",
"papermill": "papermill>=1.0.1",
"papermill": "papermill>=2.3.3",
"nteract-scrapbook": "nteract-scrapbook>=0.2.1",
"pytorch-pretrained-bert": "pytorch-pretrained-bert>=0.6",
"tqdm": "tqdm==4.31.1",
"scikit-learn": "scikit-learn>=0.19.0,<=0.20.3",
"tqdm": "tqdm>=4.62.3",
"scikit-learn": "scikit-learn>=0.19.0,<=1.0.1",
"nltk": "nltk>=3.4",
"pre-commit": "pre-commit>=1.20.0",
"spacy": "spacy>=2.2.3",
Expand Down

0 comments on commit 7629b78

Please sign in to comment.