diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..0f514164 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -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 + diff --git a/delta/ml/layers.py b/delta/ml/layers.py index cf842c01..28ad3974 100644 --- a/delta/ml/layers.py +++ b/delta/ml/layers.py @@ -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:] diff --git a/delta/ml/train.py b/delta/ml/train.py index abe14ce5..43973380 100644 --- a/delta/ml/train.py +++ b/delta/ml/train.py @@ -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(): @@ -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 diff --git a/scripts/linter/install_linter.sh b/scripts/linter/install_linter.sh index dc81eb49..50aea767 100755 --- a/scripts/linter/install_linter.sh +++ b/scripts/linter/install_linter.sh @@ -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." diff --git a/scripts/setup.sh b/scripts/setup.sh index b72600ad..8aba7f42 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -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; }