Skip to content

Commit

Permalink
Refactor the repository to make it simpler (#55)
Browse files Browse the repository at this point in the history
Ditch the eql_source_layouts package: remove MANIFEST.in, setup.py and
versioneer. Move all code inside the notebooks folder. All additional code
lives inside notebooks/source_layouts, including its test functions. Replace
os.path for pathlib. Add a new run target in the Makefile. Save
variables into JSON files and create a notebook to convert them all to LaTeX
variables. Prevent saving & loading the datasets in the same notebook. Remove
setup.cfg, move flake8 configuration to .flake8 and don't ignore F401
anymore. Add flake8-bugbear as a dependency.
  • Loading branch information
santisoler committed Oct 8, 2020
1 parent 1f53f86 commit 4738c85
Show file tree
Hide file tree
Showing 66 changed files with 1,802 additions and 20,220 deletions.
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
ignore = E203, E266, E501, W503, E741
max-line-length = 88
exclude = notebooks/.ipynb_checkpoints
per-file-ignores =
# imported but unused
__init__.py: F401

1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ jobs:
- name: Test with pytest
run: |
pip install pytest pytest-cov coverage
pip install -e .
make test
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

33 changes: 19 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# Build, package, test, and clean
PROJECT=eql_source_layouts
TESTDIR=tmp-test-dir-with-unique-name
PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --pyargs
NUMBATEST_ARGS=--doctest-modules -v --pyargs -m use_numba
LINT_FILES=setup.py $(PROJECT)
BLACK_FILES=setup.py $(PROJECT) notebooks
FLAKE8_FILES=setup.py $(PROJECT) notebooks
# Check styling and test notebooks and extra code
NOTEBOOKS=notebooks
PYTEST_ARGS=--cov --cov-report=term-missing --cov -v
LINT_FILES=$(NOTEBOOKS)
BLACK_FILES=$(NOTEBOOKS)
FLAKE8_FILES=$(NOTEBOOKS)
JUPYTEXT=jupytext --execute --set-kernel - --to notebook

help:
@echo "Commands:"
@echo ""
@echo " run run every notebook on the repository"
@echo " test run the test suite and report coverage"
@echo " format run black to automatically format the code"
@echo " check run code style and quality checks (black and flake8)"
@echo " lint run pylint for a deeper (and slower) quality check"
@echo " clean clean up build and generated files"
@echo " sync make jupytext to sync notebooks and scripts"
@echo ""


run:
$(JUPYTEXT) $(NOTEBOOKS)/*.py

sync:
jupytext --to notebook --set-kernel - $(NOTEBOOKS)/*.py

test:
# Run a tmp folder to make sure the tests are run on the installed version
mkdir -p $(TESTDIR)
cd $(TESTDIR); MPLBACKEND='agg' pytest $(PYTEST_ARGS) $(PROJECT)
cp $(TESTDIR)/.coverage* .
rm -rvf $(TESTDIR)
MPLBACKEND='agg' pytest $(PYTEST_ARGS) $(NOTEBOOKS)

format:
black $(BLACK_FILES)
Expand All @@ -37,5 +42,5 @@ lint:
clean:
find . -name "*.pyc" -exec rm -v {} \;
find . -name ".coverage.*" -exec rm -v {} \;
rm -rvf build dist MANIFEST *.egg-info __pycache__ .coverage .cache .pytest_cache
rm -rvf $(TESTDIR) dask-worker-space
rm -rvf build dist *.egg-info __pycache__ .coverage .cache .pytest_cache
rm -rvf dask-worker-space
4 changes: 1 addition & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ dependencies:
- black
- pylint
- flake8
# Install our package in editable mode
- pip:
- -e .
- flake8-bugbear
Loading

0 comments on commit 4738c85

Please sign in to comment.