Skip to content

Commit

Permalink
Merge pull request #11 from EmanueleGhelfi/pipelines
Browse files Browse the repository at this point in the history
Setup Travis and codecov
  • Loading branch information
galeone committed Jul 17, 2019
2 parents d5d58c9 + 275e18f commit e0ce972
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 6 deletions.
59 changes: 59 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
dist: xenial
language: python
addons:
artifacts: true
python:
- '3.7'
stages:
- Tests
- Black
- Pylint
- Deploy
before_install:
- sudo apt-get install -y --no-install-recommends bc
addons:
apt:
update: true
install: &requirements
- pip install -r dev-requirements.txt
- pip install -e .
jobs:
include:
- stage: Tests
install: *requirements
script:
- pip install codecov
- pip --no-cache-dir install --upgrade git+https://github.com/thisch/pytest-sphinx.git pytest
- pip --no-cache-dir install pytest-cov
- module=""
- for d in $(ls -d */); do if [ -f "$d"__init__.py ]; then module=${d::-1}; fi
done
- pytest -x -s -vvv --doctest-modules $module --cov=$module
after_success:
- codecov
- stage: Black
install: *requirements
script:
- echo excluding $(git config --file .gitmodules --get-regexp path | awk '{ print
$2 }')
- black --exclude $(git config --file .gitmodules --get-regexp path | awk '{ print
$2 }') --check .
- stage: Pylint
install: *requirements
script:
- pip --no-cache-dir install pylint-runner
- pylint_runner --rcfile=.pylintrc --output-format=text . | tee pylint.txt
- score=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' pylint.txt)
- if (( $(echo "$score < 8" |bc -l) )); then echo "Your Pylint score is too low, $score < 8!"; exit 1; fi
- stage: Deploy
script: skip
deploy:
provider: pypi
user: emanueleghelfi
password:
secure: S6XvndLnBDs64vjouhjw1l5N1eAMrCfxZt64KnNdJnn481BBoaEzY/CNV5Bp4GqPi8T7vu+AY78yT1LPT5YNazya0ywo2p3KCeQSQpgzz3gTjLbsKA6q0YXiNeLtw9X5xmpV5RoqR06+zukf8Hs/gk6HGpvW2SKG9FhTTSLKzmR4G9VJaveb9vZ8FaoK8lpuRyEYbneM92artjVV9eCYUXXa/1fNJPRhGW+q/mShtCrL/2zEVDCCXZ8oY3KgW1zNXUoPKDtg+o20002FveYrUw/0AofTMQutz+tkyvsNed3mWctA+W2YFohF70OgdiyeN8UCWWPqNOAnvvOFsWH0KSBvDmR/YUaGzk59v7WYG677j2uwD5AdZSvAMJjVqJ3D+HoHPgGj5IWpj/Ncyn65/7uQNvG4oD6i7BDKeqGoCgXTK+8TqkdzIRQEemQ4kEmbHy5EoZdQwZBASWct+jtM2hTBkkZaOwbQgKk7I+Q5RXlzg8BoNZKZGtZSG5HM5JV4b6SUUDjE/JWukHh3V1hVtgtha9yefN4TwrZ8mG0ntfsr7aPwYvmNjUi0hcdgV+/IsmHdn/fsGUfzvr8aW20aG3FeGiKO8tPAzieIHDywDBZa+tKFck1Uvei5x/nK10pSEo0zFDC3p/HjBGnoB8+JPT/TeCWrfRQW5klsPiLZ3hU=
on:
tags: true
all_branches: true
# deploy only if tag respects semantic versioning pre-pended with v (e.g. v0.1.0)
if: tag =~ /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
![PyPy - Version](https://badge.fury.io/py/ashpy.svg)
![PyPI - License](https://img.shields.io/pypi/l/ashpy.svg)
![Ashpy - Badge](https://img.shields.io/badge/package-ashpy-brightgreen.svg)
[![codecov](https://codecov.io/gh/zurutech/ashpy/branch/master/graph/badge.svg)](https://codecov.io/gh/zurutech/ashpy)
[![Build Status](https://travis-ci.org/zurutech/ashpy.svg?branch=master)](https://travis-ci.org/zurutech/ashpy)

AshPy is a TensorFlow 2.0 library for (**distributed**) training, evaluation, model selection, and fast prototyping.
It is designed to ease the burden of setting up all the nuances of the architectures built to train complex custom deep learning models.
Expand All @@ -19,11 +21,11 @@ strategy = tf.distribute.MirroredStrategy()

# work inside the scope of the created strategy
with strategy.scope():

# get the MNIST dataset
train, validation = tf.keras.datasets.mnist.load_data()

# process data if needed
# process data if needed
def process(images, labels):
data_images = tf.data.Dataset.from_tensor_slices((images)).map(
lambda x: tf.reshape(x, (28 * 28,))
Expand All @@ -49,10 +51,10 @@ with strategy.scope():
tf.keras.layers.Dense(10),
]
)

# define the optimizer
optimizer = tf.optimizers.Adam(1e-3)

# the loss is provided by the AshPy library
loss = ClassifierLoss(tf.losses.SparseCategoricalCrossentropy(from_logits=True))
logdir = "testlog"
Expand All @@ -69,12 +71,12 @@ with strategy.scope():
tf.metrics.BinaryAccuracy(), model_selection_operator=operator.gt
),
]

# define the AshPy trainer
trainer = ClassifierTrainer(
model, optimizer, loss, epochs, metrics, logdir=logdir
)

# run the training process
trainer(train, validation)
```
Expand Down
19 changes: 19 additions & 0 deletions dev-requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Core packages
# uncomment the following line to install the gpu-version
# tensorflow-gpu==2.0.0b1
tensorflow==2.0.0b1
tensorflow_hub

# Code Style
black
pylint
flake8
isort
rope
mypy

# Testing
pytest

# pytest-sphix
#git+https://github.com/thisch/pytest-sphinx.git
58 changes: 58 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file=dev-requirements.txt --pre dev-requirements.in
#
absl-py==0.7.1 # via tb-nightly, tensorflow
appdirs==1.4.3 # via black
astor==0.8.0 # via tensorflow
astroid==2.2.5 # via pylint
atomicwrites==1.3.0 # via pytest
attrs==19.1.0 # via black, pytest
black==19.3b0
click==7.0 # via black
entrypoints==0.3 # via flake8
flake8==3.7.8
gast==0.2.2 # via tensorflow
google-pasta==0.1.7 # via tensorflow
grpcio==1.22.0 # via tb-nightly, tensorflow
h5py==2.9.0 # via keras-applications
importlib-metadata==0.18 # via pluggy, pytest
isort==4.3.21
keras-applications==1.0.8 # via tensorflow
keras-preprocessing==1.1.0 # via tensorflow
lazy-object-proxy==1.4.1 # via astroid
markdown==3.1.1 # via tb-nightly
mccabe==0.6.1 # via flake8, pylint
more-itertools==7.1.0 # via pytest
mypy-extensions==0.4.1 # via mypy
mypy==0.720
numpy==1.16.4 # via h5py, keras-applications, keras-preprocessing, tb-nightly, tensorflow, tensorflow-hub
packaging==19.0 # via pytest
pluggy==0.12.0 # via pytest
protobuf==3.9.0 # via tb-nightly, tensorflow, tensorflow-hub
py==1.8.0 # via pytest
pycodestyle==2.5.0 # via flake8
pyflakes==2.1.1 # via flake8
pylint==2.3.1
pyparsing==2.4.0 # via packaging
pytest==5.0.1
rope==0.14.0
six==1.12.0 # via absl-py, astroid, grpcio, h5py, keras-preprocessing, packaging, protobuf, tb-nightly, tensorflow, tensorflow-hub
tb-nightly==1.14.0a20190603 # via tensorflow
tensorflow-hub==0.5.0
tensorflow==2.0.0b1
termcolor==1.1.0 # via tensorflow
tf-estimator-nightly==1.14.0.dev2019060501 # via tensorflow
toml==0.10.0 # via black
typed-ast==1.4.0 # via astroid, mypy
typing-extensions==3.7.4 # via mypy
wcwidth==0.1.7 # via pytest
werkzeug==0.15.4 # via tb-nightly
wheel==0.33.4 # via tb-nightly, tensorflow
wrapt==1.11.2 # via astroid, tensorflow
zipp==0.5.2 # via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# setuptools==41.0.1 # via markdown, protobuf, tb-nightly

0 comments on commit e0ce972

Please sign in to comment.