Skip to content

Commit

Permalink
Simplified project and test setup 🧯 (#38)
Browse files Browse the repository at this point in the history
* add some tools to project definition πŸͺš

* get pyproject.toml and tox up and running πŸͺš

* Fixed `types-PyYAML` issue 🐞

* Removed outdated files 🎍

* Applied pre-commit hooks to all files πŸͺ

* Reordered imports βœ…

* Updated dependencies and docs on `tox` 🧯

* Updated `start.sh` in docker container 🐳
  • Loading branch information
KarelZe authored Nov 20, 2022
1 parent 4fd5c7a commit 50df48b
Show file tree
Hide file tree
Showing 45 changed files with 358 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**/.DS_Store
**/Thumbs.db
**/*.pyc
.DS_Store
.DS_Store
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
exclude = __init__.py
extend-ignore = E203
max-complexity = 10
max-line-length = 88
2 changes: 1 addition & 1 deletion .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ changelog:
- writing
- title: Other Changes
labels:
- "*"
- "*"
2 changes: 1 addition & 1 deletion .github/workflows/action_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/stack:latest
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/stack:latest
2 changes: 1 addition & 1 deletion .github/workflows/action_latex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
with:
files: |
reports/expose.pdf
reports/TOC.pdf
reports/TOC.pdf
2 changes: 1 addition & 1 deletion .github/workflows/action_python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
run: |
pip install pytest
pip install pytest-cov
pytest --cov=src tests/ --doctest-modules --junitxml=junit/test-results.xml --cov-report=xml --cov-report=html
pytest --cov=src tests/ --doctest-modules --junitxml=junit/test-results.xml --cov-report=xml --cov-report=html
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ nosetests.xml
coverage.xml
*.cover
junit/
cover/

# Translations
*.mo
Expand Down Expand Up @@ -416,7 +417,10 @@ presentation.pdf
/artifacts/

# catboost
(catboost_info/
**/catboost_info/

# models
./models/
/models/

#venv
.venv/
49 changes: 36 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pycqa/isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: check-builtin-literals
- id: check-byte-order-marker
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- repo: https://github.com/PyCQA/autoflake
rev: v1.7.7
hooks:
- id: autoflake
args:
- "--check"
- "--ignore-init-module-imports"
- "--remove-all-unused-imports"
- "--remove-unused-variables"
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args:
- "--check-only"
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
# yaml requires additional stubs.
# Similar to: https://stackoverflow.com/a/73603491/5755604
additional_dependencies: ['types-PyYAML']
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-use-type-annotations
- id: python-use-type-annotations
- repo: https://github.com/PyCQA/doc8
rev: v1.0.0
hooks:
Expand All @@ -27,17 +57,10 @@ repos:
rev: 22.10.0
hooks:
- id: black
args:
- "--check"
language_version: python3
exclude: ^(tests\/hooks-abort-render\/hooks|docs\/HelloCookieCutter1)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-byte-order-marker
- id: check-merge-conflict
- id: check-symlinks
- id: check-builtin-literals
exclude: ^(tests\/hooks-abort-render\/hooks|docs)
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
Expand All @@ -51,4 +74,4 @@ repos:
rev: v3.2.2
hooks:
- id: pyupgrade
exclude: '^references/'
exclude: "^(references|reports)"
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ title: "Option Trade Classification with Machine Learning"
version: 0.0.1
doi: 00.0000/zenodo.1234
date-released: 2023-03-31
url: "https://github.com/KarelZe/thesis"
url: "https://github.com/KarelZe/thesis"
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,3 @@ RUN mkdir -p $HOME/.vscode/extensions/ && \
unzip - njpwerner.autodocstring-latest.zip extension/* && \
rm njpwerner.autodocstring-latest.zip && \
mv extension $HOME/.vscode/extensions/njpwerner.autodocstring-latest


1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.

144 changes: 0 additions & 144 deletions Makefile

This file was deleted.

10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@ python src/models/train_model.py --trials=5 --seed=42 --model=gbm --dataset=fbv/

### Build and run docker image 🐳
The code is designed to run inside a docker container. See the [`Dockerfile`](https://github.com/KarelZe/thesis/blob/main/Dockerfile).
```
```shell
docker build -t thesis-dev .
docker run --env-file .env thesis-dev
```

### Set up git pre-commit hooks πŸ™
Pre-commit hooks are pre-checks to avoid committing error-prone code. The tests are defined in the [`.pre-commit-config.yaml`](https://github.com/KarelZe/thesis/blob/main/.pre-commit-config.yaml). Install them using:
```
```shell
pip install .[dev]
pre-commit install
pre-commit run --all-files
```

### Run tests🧯
Tests can be run using [`tox`](https://tox.wiki/en/latest/). Just type:
```shell
tox
```
## Acknowledgement
Our implementation is based on:

Expand Down
Loading

0 comments on commit 50df48b

Please sign in to comment.