Skip to content

Commit

Permalink
Upgrade Explain Tests to Python3.8 and format selectively (#275)
Browse files Browse the repository at this point in the history
* add np

* Update setup.py

* display yapf version

* print yapf version

* fix fmt signature

* fmt explain

* Use PIL.Image.LANCZOS

* apply formatting to specific package

* use python38

* apply eval formatting

* fmt
  • Loading branch information
coreyhu authored Jul 11, 2023
1 parent 83b2cc6 commit c87707d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 28 deletions.
7 changes: 4 additions & 3 deletions .azure_pipelines/ci-eval-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ jobs:
source activate $(condaEnvFileSuffix)
pip install yapf==0.32.0
pip install isort==5.10.1
./format.sh
echo Using $(yapf --version) isort $(isort --vn)
./format.sh --eval
displayName: Format Code
- bash: |
num_changed_files=`git ls-files --others -m --exclude-standard | wc -l`
num_changed_files=`git ls-files --others -m --exclude-standard ./trulens_eval | wc -l`
if [ $num_changed_files -ne 0 ]; then
echo "The following files have changed after running format.sh. Please format your code and update the PR."
git ls-files --others -m --exclude-standard
git ls-files --others -m --exclude-standard ./trulens_eval
echo "\n\nOutputting git diff for checked in files.\n"
git diff
fi
Expand Down
7 changes: 4 additions & 3 deletions .azure_pipelines/ci-eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ jobs:
- bash: |
set -e
source activate $(condaEnvFileSuffix)
./format.sh
echo Using $(yapf --version) isort $(isort --vn)
./format.sh --eval
displayName: Format Code
- bash: |
num_changed_files=`git ls-files --others -m --exclude-standard | wc -l`
num_changed_files=`git ls-files --others -m --exclude-standard ./trulens_eval | wc -l`
if [ $num_changed_files -ne 0 ]; then
echo "The following files have changed after running format.sh. Please format your code and update the PR."
git ls-files --others -m --exclude-standard
git ls-files --others -m --exclude-standard ./trulens_eval
echo "\n\nOutputting git diff for checked in files.\n"
git diff
fi
Expand Down
32 changes: 16 additions & 16 deletions .azure_pipelines/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,33 @@ jobs:

strategy:
matrix:
py37_tf1_keras:
condaEnvFileSuffix: "python37"
py38_tf1_keras:
condaEnvFileSuffix: "python38"
requirementsFile: "tests/keras/requirements_tfv1.txt"
testSubdirectory: "tests/keras"

py37_tf1_tf_keras:
condaEnvFileSuffix: "python37"
py38_tf1_tf_keras:
condaEnvFileSuffix: "python38"
requirementsFile: "tests/tf_keras/requirements_tfv1.txt"
testSubdirectory: "tests/tf_keras"

py37_pytorch:
condaEnvFileSuffix: "python37"
py38_pytorch:
condaEnvFileSuffix: "python38"
requirementsFile: "tests/pytorch/requirements.txt"
testSubdirectory: "tests/pytorch"

py37_tf1:
condaEnvFileSuffix: "python37"
py38_tf1:
condaEnvFileSuffix: "python38"
requirementsFile: "tests/tf/requirements.txt"
testSubdirectory: "tests/tf"

py37_tf2:
condaEnvFileSuffix: "python37"
py38_tf2:
condaEnvFileSuffix: "python38"
requirementsFile: "tests/tf2/requirements.txt"
testSubdirectory: "tests/tf2"

py37_tf2_non_eager:
condaEnvFileSuffix: "python37"
py38_tf2_non_eager:
condaEnvFileSuffix: "python38"
requirementsFile: "tests/tf2/requirements.txt"
testSubdirectory: "tests/tf2_non_eager"

Expand Down Expand Up @@ -92,14 +92,14 @@ jobs:
- bash: |
set -e
source activate $(condaEnvFileSuffix)
echo Using yapf $(yapf --version)
./format.sh
echo Using $(yapf --version) isort $(isort --vn)
./format.sh --explain
displayName: Format Code
- bash: |
num_changed_files=`git ls-files --others -m --exclude-standard | wc -l`
num_changed_files=`git ls-files --others -m --exclude-standard ./trulens_explain | wc -l`
if [ $num_changed_files -ne 0 ]; then
echo "The following files have changed after running format.sh. Please format your code and update the PR."
git ls-files --others -m --exclude-standard
git ls-files --others -m --exclude-standard ./trulens_explain
echo "\n\nOutputting git diff for checked in files.\n"
git diff
fi
Expand Down
16 changes: 13 additions & 3 deletions format.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#/bin/bash
if [ $# -eq 0 ] ; then
FORMAT_PATH=.
elif [ $1 = "--explain" ]; then
FORMAT_PATH=./trulens_explain
elif [ $1 = "--eval" ]; then
FORMAT_PATH=./trulens_eval
else
echo "Got invalid flag $1"
exit 1
fi

isort .

yapf --style .style.yapf -r -i --verbose --parallel -r -i .
echo "Formatting $FORMAT_PATH"
isort $FORMAT_PATH
yapf --style .style.yapf -r -i --verbose --parallel -r -i $FORMAT_PATH
2 changes: 1 addition & 1 deletion trulens_explain/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

SHELL:=bash
ACTIVATE:=source $$(conda info --base)/etc/profile.d/conda.sh ; conda activate ; conda activate
CONDA_ENV:=python37
CONDA_ENV:=python38
TEST_ENV:=PYTHONPATH=. CUDA_VISIBLE_DEVICES=

format:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#TODO: This is incomplete and does not include all the dependencies required for development.
name: python37
name: python38
channels:
- defaults
dependencies:
Expand Down Expand Up @@ -30,4 +30,4 @@ dependencies:
- python-markdown-math==0.7
- yapf==0.32.0
- isort==5.10.1
prefix: /home/truera/miniconda3/envs/python37
prefix: /home/truera/miniconda3/envs/python38

0 comments on commit c87707d

Please sign in to comment.