Skip to content

Commit

Permalink
pr/33: Merge branch 'release/0.7.3' into pr/33
Browse files Browse the repository at this point in the history
  • Loading branch information
nok committed Apr 5, 2019
2 parents 672e018 + b9b0c31 commit 61e177f
Show file tree
Hide file tree
Showing 271 changed files with 11,337 additions and 25,688 deletions.
411 changes: 382 additions & 29 deletions .gitignore

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,protected-access

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
6 changes: 6 additions & 0 deletions .scripts/install.environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

conda env create -n sklearn-porter -f $SCRIPTPATH/../environment.yml
source activate sklearn-porter
8 changes: 8 additions & 0 deletions .scripts/install.function.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

read -r -p "Install function 'porter' to ~/.bash_profile? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
cat $SCRIPTPATH/function.sh >> ~/.bash_profile
source ~/.bash_profile
fi
8 changes: 8 additions & 0 deletions .scripts/install.requirements.development.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

pip freeze | grep --quiet twine
if [[ $? -eq 1 ]]; then
pip install -q --no-cache-dir -r $SCRIPTPATH/../requirements.development.txt
fi
8 changes: 8 additions & 0 deletions .scripts/install.requirements.examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

pip freeze | grep --quiet jupyter-lab
if [[ $? -eq 1 ]]; then
pip install -q --no-cache-dir -r $SCRIPTPATH/../requirements.examples.txt
fi
8 changes: 8 additions & 0 deletions .scripts/install.requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

pip freeze | grep --quiet scikit-learn
if [[ $? -eq 1 ]]; then
pip install -q --no-cache-dir -r $SCRIPTPATH/../requirements.txt
fi
26 changes: 26 additions & 0 deletions .scripts/run.deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# Set local variables:
NAME=sklearn-porter
ANACONDA_ENV=sklearn-porter

source activate $ANACONDA_ENV

VERSION=`python -c "from sklearn_porter import __version__ as ver; print(ver);"`
COMMIT=`git rev-parse --short HEAD`

# Environment:
TARGET="https://upload.pypi.org/legacy/"
read -r -p "Do you want to use the staging environment (test.pypi.org)? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
TARGET="https://test.pypi.org/legacy/"
fi

# Build the package:
python ./setup.py sdist bdist_wheel

# Upload the package:
read -r -p "Upload $NAME@$VERSION (#$COMMIT) to '$TARGET'? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
twine upload ./dist/* --repository-url $TARGET
fi
20 changes: 20 additions & 0 deletions .scripts/run.jupytext.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

cd $SCRIPTPATH/../examples/estimator

for py_file in $(find . -type f -name '*.pct.py')
do
ipynp_file="${py_file%.py}.ipynb"
echo "$py_file"
echo "$ipynp_file"
jupytext --from "py:percent" --to "notebook" "$py_file"
jupyter nbconvert --to notebook --execute "$ipynp_file" --output $(basename -- "$ipynp_file")
done

for json_file in $(find . -type f -name 'data.json')
do
echo "$json_file"
rm -f "$json_file"
done
37 changes: 37 additions & 0 deletions .scripts/run.tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

cd $SCRIPTPATH/..

# Dependencies:
if [[ ! -f ./gson.jar ]]; then
wget http://central.maven.org/maven2/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar
mv gson-2.8.5.jar gson.jar
fi

# Local server:
if [[ $(python -c "import sys; print(sys.version_info[:1][0]);") == "2" ]]; then
python -m SimpleHTTPServer 8713 &>/dev/null & serve_pid=$!;
else
python -m http.server 8713 &>/dev/null & serve_pid=$!;
fi

# Test params:
if [[ -z "${TEST_N_RANDOM_FEATURE_SETS}" ]]; then
TEST_N_RANDOM_FEATURE_SETS=25
fi
if [[ -z "${TEST_N_EXISTING_FEATURE_SETS}" ]]; then
TEST_N_EXISTING_FEATURE_SETS=25
fi

# Tests:
TEST_N_RANDOM_FEATURE_SETS=${TEST_N_RANDOM_FEATURE_SETS} \
TEST_N_EXISTING_FEATURE_SETS=${TEST_N_EXISTING_FEATURE_SETS} \
pytest tests -v -x -p no:doctest
success=$?

kill $serve_pid
rm gson.jar

exit $success
55 changes: 15 additions & 40 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,32 @@ dist: trusty
notifications:
email: false
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
node_js:
- "6"
php:
- "7.0"
- 2.7
- 3.4
- 3.5
- 3.6
matrix:
include:
- python: 3.7
dist: xenial
sudo: true
cache: pip
compiler:
- gcc
before_install:
- SKLEARN_PORTER_HOME=$(pwd)
- sudo apt-add-repository ppa:brightbox/ruby-ng -y
- sudo apt-add-repository ppa:ondrej/php -y
- sudo apt-get update -q
- unset JAVA_TOOL_OPTIONS && unset _JAVA_OPTIONS
install:
- sudo apt-get install ruby2.3 -y
- sudo ln -s /usr/local/ruby2.3 /usr/local/ruby
- sudo apt-get install php7.0 -y
- wget -O gson.jar http://central.maven.org/maven2/com/google/code/gson/gson/2.8.2/gson-2.8.2.jar
- npm install xmlhttprequest
- unset JAVA_TOOL_OPTIONS && unset _JAVA_OPTIONS
- if [[ "${TRAVIS_PYTHON_VERSION:0:1}" == "2" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda config --add channels conda-forge
- conda update -q conda
- conda install -n root _license
- conda info -a
- conda create -y -n sklearn-porter python=$TRAVIS_PYTHON_VERSION
- source activate sklearn-porter
- pip install -U pip
- pip install -r requirements.txt
- python --version
- make install.requirements.development
before_script:
- gcc --version
- java -version
- node --version
- go version
- php --version
- ruby --version
before_script:
- if [[ "${TRAVIS_PYTHON_VERSION:0:1}" == "2" ]]; then
python -m SimpleHTTPServer 8080 &>/dev/null &
else
python -m http.server 8080 &>/dev/null &
fi
- python --version
script:
- python -m unittest discover -vp '*Test.py'
- make test
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include readme.md requirements.txt changelog.md license.txt
recursive-include sklearn_porter *.txt *.py
recursive-include sklearn_porter *.py *.txt *.json
77 changes: 77 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
BASH := /bin/bash

PYTHON_FILES := $(shell find -s ./sklearn_porter -name '*.py' | tr '\n' ' ')

TEST_N_RANDOM_FEATURE_SETS=25
TEST_N_EXISTING_FEATURE_SETS=25

#
# Requirements
#

install.environment:
$(info Start [install.environment] ...)
$(BASH) .scripts/install.environment.sh

install.requirements:
$(info Start [install.requirements] ...)
$(BASH) .scripts/install.requirements.sh

install.requirements.examples: install.requirements
$(info Start [install.requirements.examples] ...)
$(BASH) .scripts/install.requirements.examples.sh

install.requirements.development: install.requirements.examples
$(info Start [install.requirements.development] ...)
$(BASH) .scripts/install.requirements.development.sh

#
# Examples
#

open.examples: install.requirements.examples examples.pid

examples.pid:
$(info Start [examples.pid] ...)
jupyter-lab --notebook-dir='examples' > /dev/null 2>&1 & echo $$! > $@;

stop.examples: examples.pid
kill `cat $<` && rm $<

.PHONY: open.examples stop.examples

#
# Development
#

all: lint test jupytext clean

lint: install.requirements.development
$(info Start [lint] ...)
pylint --rcfile=.pylintrc --output-format=text $(PYTHON_FILES) 2>&1 | tee pylint.txt | sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p'

test: install.requirements.development
$(info Start [test] ...)
TEST_N_RANDOM_FEATURE_SETS=$(TEST_N_RANDOM_FEATURE_SETS) \
TEST_N_EXISTING_FEATURE_SETS=$(TEST_N_EXISTING_FEATURE_SETS) \
$(BASH) .scripts/run.tests.sh

test.sample: install.requirements.development
$(info Start [test.sample] ...)
TEST_N_RANDOM_FEATURE_SETS=3 \
TEST_N_EXISTING_FEATURE_SETS=3 \
$(BASH) .scripts/run.tests.sh

jupytext: install.requirements.development
$(info Start [jupytext] ...)
$(BASH) .scripts/run.jupytext.sh

deploy: clean
$(info Start [deploy.test] ...)
$(BASH) .scripts/run.deployment.sh

clean:
$(info Start [clean] ...)
rm -rf tmp
rm -rf build
rm -rf dist
Loading

0 comments on commit 61e177f

Please sign in to comment.