Skip to content

Commit

Permalink
Gha testing (#111)
Browse files Browse the repository at this point in the history
Add GHA-based continuous integration
  • Loading branch information
ribhavb committed Sep 16, 2021
1 parent 736eaed commit 1ec7b1e
Show file tree
Hide file tree
Showing 7 changed files with 390 additions and 9 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/daily-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: daily-testing

on:
push:
branches:
- gha-testing
- master
schedule:
# daily testing to occur at 7:30 CST every Monday
- cron: '30 13 * * 1'
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['']
keras-version: ['']
tf-version: ['']
include:
- python-version: 3.9
keras-version: TF
tf-version: 2.5
label: latest-tf

- python-verison: 3.9
keras-version: SKLEARN
label: sklearn

- python-version: 3.9
keras-version: 2.1.3
tf-version: 2.5
label: keras-2.1.3

- python-version: 3.9
keras-version: 2.2.3
tf-version: 2.5
label: keras-2.2.3



env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
SCIKIT_LEARN_VERSION: '0.19.1'

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Globus auth
run: 'echo "$GLOBUS_CONFIG" > ~/.globus-native-apps.cfg'
shell: bash
env:
GLOBUS_CONFIG: "${{ secrets.GLOBUS_CONFIG }}"

- name: Run Installation Script
run: |
python -m pip install --upgrade pip
pip install -e .
pip install flake8 pytest
pip install -r test-requirements.txt
if ${{ matrix.keras-version == '2.2.3' }}; then
pip install tensorflow==${{matrix.tf-version}}
pip install keras==${{matrix.keras-version}}
fi
if ${{ matrix.keras-version == '2.1.3' }}; then
pip install tensorflow==${{matrix.tf-version}}
pip install keras==${{matrix.keras-version}}
fi
if ${{matrix.keras-version == 'TF'}}; then
pip install tensorflow==${{matrix.tf-version}}
fi
if ${{matrix.keras-version == 'SKLEARN' }}; then
pip install scikit-learn
fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip list
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
# run all testing documents, except the local tests
pytest ./dlhub_sdk -k "not test_dlhub_client"
2 changes: 2 additions & 0 deletions dlhub_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,5 @@ def clear_funcx_cache(self, servable=None):
self.fx_cache = {}

return self.fx_cache


26 changes: 21 additions & 5 deletions dlhub_sdk/models/servables/tests/test_keras.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
from datetime import datetime
import pytest
import os



try:
import keras
keras_installed = True


except ImportError:
keras_installed = False
from tensorflow import keras
from pytest import raises

try:
from tensorflow import keras
keras_installed = True

except ImportError:
keras_installed = False

no_keras = pytest.mark.skipif(keras_installed == False, reason='keras not installed')



from dlhub_sdk.models.servables.keras import KerasModel
from dlhub_sdk.utils.schemas import validate_against_dlhub_schema

print(keras_installed)

_year = str(datetime.now().year)

Expand All @@ -24,6 +39,7 @@ def _make_simple_model():
return model


@no_keras
def test_keras_single_input(tmpdir):
# Make a Keras model
model = _make_simple_model()
Expand All @@ -41,7 +57,7 @@ def test_keras_single_input(tmpdir):
output = metadata.to_dict()
validate_against_dlhub_schema(output, 'servable')


@no_keras
def test_keras_multioutput(tmpdir):
# Make a Keras model
input_layer = keras.layers.Input(shape=(4,))
Expand Down Expand Up @@ -73,7 +89,7 @@ def test_keras_multioutput(tmpdir):
# Validate against schema
validate_against_dlhub_schema(output, 'servable')


@no_keras
def test_custom_layers(tmpdir):
"""Test adding custom layers to the definition"""

Expand All @@ -95,7 +111,7 @@ def test_custom_layers(tmpdir):
# Validate it against DLHub schema
validate_against_dlhub_schema(metadata.to_dict(), 'servable')


@no_keras
def test_multi_file(tmpdir):
"""Test adding the architecture in a different file """

Expand Down
17 changes: 14 additions & 3 deletions dlhub_sdk/models/servables/tests/test_tensorflow.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
"""Testing the tensorflow adaptor"""
import tensorflow as tf
import pytest
import shutil
import os

from pytest import fixture

from dlhub_sdk.models.servables.tensorflow import TensorFlowModel
from dlhub_sdk.utils.schemas import validate_against_dlhub_schema

try:
import tensorflow as tf
from dlhub_sdk.models.servables.tensorflow import TensorFlowModel
tf_installed = True
except ImportError:
tf_installed = False




no_tf = pytest.mark.skipif(tf_installed == False, reason='tf not installed')

# Do not write to a temp directory so I can see it outside of tests
tf_export_path = os.path.join(os.path.dirname(__file__), 'tf-model')

Expand Down Expand Up @@ -112,6 +122,7 @@ def setUp():
shutil.rmtree(tf_export_path)


@no_tf
def test_tf():
# Make a model and save it to disk
if tf.__version__ < '2':
Expand Down

0 comments on commit 1ec7b1e

Please sign in to comment.