Skip to content

Commit

Permalink
Improve the development flow and extend the README with steps recomme…
Browse files Browse the repository at this point in the history
…nded before submitting a PR (#544)
  • Loading branch information
izeigerman authored Oct 5, 2022
1 parent 9b8e5db commit 9784632
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 30 deletions.
16 changes: 2 additions & 14 deletions .ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,7 @@
set -e

if [[ $TEST == "API" ]]; then
# Run code linters
flake8 .
isort . --check-only
# Run tests with code coverage
pytest -v tests/ --cov=m2cgen/ --cov-report=xml:coverage.xml --ignore=tests/e2e/
# Upload code coverage
wget -q https://uploader.codecov.io/latest/linux/codecov -O codecov
chmod +x codecov
./codecov -f coverage.xml -Z
# Generate code examples
python setup.py develop
python tools/generate_code_examples.py ./generated_code_examples
make flake8 isort-check test-api run-codecov generate-code-examples
fi

if [[ $TEST == "E2E" ]]; then
Expand All @@ -24,6 +13,5 @@ if [[ $TEST == "E2E" ]]; then
fi

if [[ $RELEASE == "true" ]]; then
python setup.py bdist_wheel --plat-name=any --python-tag=py3
python setup.py sdist
make package
fi
58 changes: 48 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
DOCKER_IMAGE := m2cgen
DOCKER_RUN_ARGS := docker run --rm -it -v "$$PWD":"/m2cgen" $(DOCKER_IMAGE)
TARGETS := ./m2cgen ./tests

clean:
rm -rf ./m2cgen.egg-info ./dist ./build

docker-build:
docker build -t $(DOCKER_IMAGE) .
flake8:
flake8 $(TARGETS)

isort:
isort $(TARGETS)

isort-check:
isort $(TARGETS) --check-only

test-api:
pytest -v tests/ --cov=m2cgen/ --cov-report=xml:coverage.xml --ignore=tests/e2e/

package:
python setup.py bdist_wheel --plat-name=any --python-tag=py3 && \
python setup.py sdist

publish: clean package
python -m twine upload dist/*

install-requirements:
pip install -r requirements-test.txt

install-develop:
python setup.py develop

docker-test-all:
$(DOCKER_RUN_ARGS)
pre-pr: install-requirements flake8 isort test-api

docker-test-unit:
$(DOCKER_RUN_ARGS) bash -c "pytest -v --fast tests/ --ignore=tests/e2e/"
generate-code-examples: install-develop
python tools/generate_code_examples.py ./generated_code_examples

download-codecov:
wget -q https://uploader.codecov.io/latest/linux/codecov -O codecov && \
chmod +x codecov

run-codecov: download-codecov
./codecov -f coverage.xml -Z

docker-build:
docker build -t $(DOCKER_IMAGE) .

docker-generate-examples:
$(DOCKER_RUN_ARGS) bash -c "python setup.py develop && python tools/generate_code_examples.py generated_code_examples"
$(DOCKER_RUN_ARGS) make generate-code-examples

docker-lint:
$(DOCKER_RUN_ARGS) bash -c "flake8 . && isort . --check-only"
$(DOCKER_RUN_ARGS) make flake8 isort-check

docker-test-api:
$(DOCKER_RUN_ARGS) make test-api

docker-pre-pr:
$(DOCKER_RUN_ARGS) make pre-pr

docker-shell:
$(DOCKER_RUN_ARGS) bash

docker-pre-pr: docker-lint docker-test-all
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
**m2cgen** (Model 2 Code Generator) - is a lightweight library which provides an easy way to transpile trained statistical models into a native code (Python, C, Java, Go, JavaScript, Visual Basic, C#, PowerShell, R, PHP, Dart, Haskell, Ruby, F#, Rust, Elixir).

* [Installation](#installation)
* [Development](#development)
* [Supported Languages](#supported-languages)
* [Supported Models](#supported-models)
* [Classification Output](#classification-output)
Expand All @@ -23,6 +24,15 @@ Supported Python version is >= **3.7**.
pip install m2cgen
```

## Development
Make sure the following command runs successfully before submitting a PR:
```
make pre-pr
```
Alternatively you can run the Docker version of the same command:
```
make docker-build docker-pre-pr
```

## Supported Languages

Expand Down
2 changes: 1 addition & 1 deletion m2cgen/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.1
0.10.1
16 changes: 11 additions & 5 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Other stuff
numpy==1.23.3; python_version > "3.7"
numpy==1.21.5; python_version <= "3.7"
scipy==1.9.1; python_version > "3.7"
scipy==1.7.3; python_version <= "3.7"

# Cython
Cython==0.29.32; sys_platform == 'darwin' and platform_machine == 'arm64'

# Supported models
scikit-learn==1.0.2
xgboost==1.6.2
Expand All @@ -13,8 +22,5 @@ pytest-mock==3.8.2
pytest-cov==3.0.0
py-mini-racer==0.6.0

# Other stuff
numpy==1.23.3; python_version > "3.7"
numpy==1.21.5; python_version <= "3.7"
scipy==1.9.1; python_version > "3.7"
scipy==1.7.3; python_version <= "3.7"
# Publishing
twine

0 comments on commit 9784632

Please sign in to comment.