Skip to content

Commit

Permalink
Github Continuous Integration (#2)
Browse files Browse the repository at this point in the history
* Add github actions for linter and unit testing.
  • Loading branch information
bcoltin authored Jun 12, 2020
1 parent a68c195 commit 8caffe8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Linting and testing on commit
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: DELTA Continuous Integration

on:
push:
branches: [ 'master', 'develop' ]
pull_request:
branches: [ 'master', 'develop' ]

jobs:
continuous_integration:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install DELTA
run: |
./scripts/setup.sh
python3 -m pip install pylint pytest
python3 -m pip install .
- name: Lint with pylint
run: |
find . -type f -name "*.py" | xargs --null --no-run-if-empty ./scripts/linter/lint
- name: Test with pytest
run: |
pytest tests
4 changes: 2 additions & 2 deletions delta/ml/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def get_config(self):
def callback(self):
kl_enabled = self._kl_enabled
class GaussianSampleCallback(Callback):
def on_epoch_begin(self, epoch, _): # pylint:disable=no-self-use
def on_epoch_begin(self, epoch, _=None): # pylint:disable=no-self-use
if epoch > 0:
K.set_value(kl_enabled, 1.0)
return GaussianSampleCallback()

def call(self, inputs):
def call(self, inputs, **_):
mean, log_var = inputs
batch = K.shape(mean)[0]
dim = K.int_shape(mean)[1:]
Expand Down
6 changes: 3 additions & 3 deletions delta/ml/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ def __init__(self, temp_dir):
self.batch = 0
self.temp_dir = temp_dir

def on_epoch_end(self, epoch, _):
def on_epoch_end(self, epoch, _=None):
self.epoch = epoch

def on_train_batch_end(self, batch, logs):
def on_train_batch_end(self, batch, logs=None):
self.batch = batch
if batch % config.mlflow.frequency() == 0:
for k in logs.keys():
Expand All @@ -127,7 +127,7 @@ def on_train_batch_end(self, batch, logs):
mlflow.log_artifact(filename, 'checkpoints')
os.remove(filename)

def on_test_batch_end(self, _, logs): # pylint:disable=no-self-use
def on_test_batch_end(self, _, logs=None): # pylint:disable=no-self-use
for k in logs.keys():
if k in ('batch', 'size'):
continue
Expand Down
2 changes: 2 additions & 0 deletions scripts/linter/install_linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

python3 -m pip install pylint

cp $DIR/pre-commit $DIR/../../.git/hooks/pre-commit
echo "Linter installed as pre-commit hook."

11 changes: 8 additions & 3 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# use this repository and key for gdal-2.0
sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 089EBE08314DF160
#sudo add-apt-repository -y ppa:ubuntugis/ppa
#sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 089EBE08314DF160
sudo apt update

sudo apt install -y python3-pip python3-dev python3-gdal || { echo >&2 "ERROR. Failed to install pip3."; exit 1; }
#sudo apt install -y python3-gdal || { echo >&2 "ERROR. Failed to install python3."; exit 1; }
sudo apt install -y python3-dev libgdal-dev || { echo >&2 "ERROR. Failed to install python3."; exit 1; }

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade setuptools requests numpy six
python3 -m pip install GDAL==`gdal-config --version` --global-option=build_ext --global-option="-I/usr/include/gdal/"

$DIR/linter/install_linter.sh || { echo >&2 "ERROR. Failed to install linter."; exit 1; }

Expand Down

0 comments on commit 8caffe8

Please sign in to comment.