Skip to content
This repository was archived by the owner on May 22, 2019. It is now read-only.

Commit 24f9f5f

Browse files
authored
Merge pull request #353 from zurk/feature/style-check
Add style check stage
2 parents 41deba3 + bfa8eaf commit 24f9f5f

105 files changed

Lines changed: 456 additions & 379 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
[flake8]
2-
max-line-length=99
2+
ignore=B008,E121,E123,E126,E226,E24,E704,W503,W504,D100,D105,D200,D301,D402
3+
max-line-length=99
4+
exclude=
5+
.git
6+
doc
7+
inline-quotes="
8+
import-order-style=appnexus
9+
application-package-names=sourced.ml
10+
per-file-ignores=
11+
**/tests/**:D
12+
# Should be resolved one by one
13+
# Related issue: https://github.com/src-d/ml/issues/354
14+
./sourced/ml/transformers/*:D
15+
./sourced/ml/extractors/*:D
16+
./sourced/ml/models/**:D
17+
./sourced/ml/algorithms/**:D
18+
./sourced/ml/utils/*:D
19+
./sourced/ml/cmd/*:D

.pylintrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[MASTER]
2+
jobs=0
3+
load-plugins=pylint.extensions.docparams
4+
5+
[MESSAGES CONTROL]
6+
disable=all
7+
enable=missing-param-doc,
8+
differing-param-doc,
9+
differing-type-doc,
10+
missing-return-doc

.travis.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cache:
77
directories:
88
- "$HOME/.cache/pip"
99
stages:
10+
- style
1011
- test
1112
- name: deploy
1213
# require any tag name to deploy
@@ -18,7 +19,8 @@ addons:
1819
_install: &_install
1920
- gimme 1.8
2021
- source ~/.gimme/envs/latest.env
21-
- pip install --upgrade pip
22+
# We need pip v18.1 to make python 3.4 work well
23+
- (wget -O - https://bootstrap.pypa.io/get-pip.py || wget -O - https://raw.githubusercontent.com/pypa/get-pip/master/get-pip.py) | python3 - pip==18.1
2224
- if [[ $TRAVIS_PYTHON_VERSION < 3.7 ]]; then pip install tensorflow; fi
2325
- pip install -r requirements.txt codecov
2426
- pip install -e .[pandas]
@@ -32,7 +34,13 @@ _deploy: &_deploy
3234
tags: true
3335
matrix:
3436
include:
35-
- python: 3.4
37+
- stage: style
38+
python: 3.7
39+
env: SCRIPT="make check && cd doc && make"
40+
install:
41+
- pip install -r doc/requirements.txt -r requirements-lint.txt
42+
- stage: test
43+
python: 3.4
3644
dist: trusty
3745
env: *_coverage
3846
install: *_install
@@ -46,18 +54,13 @@ matrix:
4654
install: *_install
4755
after_success:
4856
- codecov
49-
- python: 3.7
50-
env: *_coverage
51-
install: *_install
52-
env: SCRIPT="flake8 . && (! grep -R /tmp sourced/ml/tests)"
53-
install: pip install flake8
5457
- python: 3.7
5558
env: *_coverage
5659
install: *_install
5760
- stage: deploy
5861
python: 3.4
5962
install:
60-
- pip3 install --upgrade pip
63+
- (wget -O - https://bootstrap.pypa.io/get-pip.py || wget -O - https://raw.githubusercontent.com/pypa/get-pip/master/get-pip.py) | python3 - --user pip==18.1
6164
- pip3 install twine
6265
before_script: skip
6366
script:

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.PHONY: check
2+
check:
3+
! grep -R /tmp sourced/ml/tests
4+
flake8 --count
5+
pylint sourced.ml
6+
7+
.PHONY: docker-build
8+
docker-build:
9+
docker build -t srcd/ml .
10+
11+
.PHONY: docker-build-core
12+
docker-build-core:
13+
docker build -t srcd/ml-core --file Dockerfile.core .

doc/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Sphinx==1.7.7
2+
sphinx-autoapi==0.6.0

requirements-lint.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
flake8==3.5.0
2+
flake8-bugbear==18.8.0
3+
flake8-docstrings==1.3.0
4+
flake8-import-order==0.18
5+
flake8-quotes==1.0.0
6+
flake8-per-file-ignores==0.6
7+
pylint==2.1.1

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
from importlib.machinery import SourceFileLoader
12
import io
23
import os.path
3-
from importlib.machinery import SourceFileLoader
4-
from setuptools import setup, find_packages
4+
5+
from setuptools import find_packages, setup
56

67
sourcedml = SourceFileLoader("sourced.ml", "./sourced/ml/__init__.py").load_module()
78

89
with io.open(os.path.join(os.path.dirname(__file__), "README.md"),
9-
encoding='utf-8') as f:
10+
encoding="utf-8") as f:
1011
long_description = f.read()
1112

1213
setup(

sourced/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Common namespace for sourced tools."""
12
# You must not include any other code and data in a namespace package's __init__.py
23
import pkg_resources
34
pkg_resources.declare_namespace(__name__)

sourced/ml/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""MLonCode research playground."""
12
try:
23
import modelforge.configuration
34

sourced/ml/__main__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55

66
from modelforge import slogging
77

8-
from sourced.ml import extractors
9-
from sourced.ml.transformers import Moder
108
from sourced.ml import cmd
9+
from sourced.ml import extractors
1110
from sourced.ml.cmd import args
1211
from sourced.ml.cmd.run_swivel import mirror_tf_args
12+
from sourced.ml.transformers import Moder
1313
from sourced.ml.utils import install_bigartm
1414
from sourced.ml.utils.spark import add_spark_args
1515

1616

1717
def get_parser() -> argparse.ArgumentParser:
1818
"""
19-
Creates the cmdline argument parser.
19+
Create the cmdline argument parser.
2020
"""
21-
2221
parser = argparse.ArgumentParser(formatter_class=args.ArgumentDefaultsHelpFormatterNoNone)
2322
parser.add_argument("--log-level", default="INFO",
2423
choices=logging._nameToLevel,
@@ -337,10 +336,10 @@ def add_parser(name, help_message):
337336

338337
def main():
339338
"""
340-
Creates all the argparse-rs and invokes the function from set_defaults().
339+
Create all the argparse-rs and invokes the function from set_defaults().
340+
341341
:return: The result of the function from set_defaults().
342342
"""
343-
344343
parser = get_parser()
345344
args = parser.parse_args()
346345
args.log_level = logging._nameToLevel[args.log_level]

0 commit comments

Comments
 (0)