Makefile 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. .PHONY: clean dirs virtualenv lint requirements push pull reproduce
  2. #################################################################################
  3. # GLOBALS #
  4. #################################################################################
  5. PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
  6. PYTHON_INTERPRETER = python
  7. #################################################################################
  8. # COMMANDS #
  9. #################################################################################
  10. ## Create virtualenv.
  11. ## Activate with the command:
  12. ## source env/bin/activate
  13. virtualenv:
  14. virtualenv -p $(PYTHON_INTERPRETER) env
  15. ## Install Python Dependencies.
  16. ## Make sure you activate the virtualenv first!
  17. requirements:
  18. $(PYTHON_INTERPRETER) -m pip install -U pip setuptools wheel
  19. $(PYTHON_INTERPRETER) -m pip install -r requirements.txt
  20. ## Create directories that are ignored by git but required for the project
  21. dirs:
  22. mkdir -p data/raw data/processed models
  23. ## Delete all compiled Python files
  24. clean:
  25. find . -type f -name "*.py[co]" -delete
  26. find . -type d -name "__pycache__" -delete
  27. ## Lint using flake8
  28. lint:
  29. flake8 src
  30. ## Upload Data to default DVC remote
  31. push:
  32. dvc push
  33. ## Download Data from default DVC remote
  34. pull:
  35. dvc pull
  36. ## Reproduce the DVC pipeline - recompute any modified outputs such as processed data or trained models
  37. reproduce:
  38. dvc repro eval.dvc
  39. #################################################################################
  40. # PROJECT RULES #
  41. #################################################################################
  42. #################################################################################
  43. # Self Documenting Commands #
  44. #################################################################################
  45. .DEFAULT_GOAL := help
  46. # Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
  47. # sed script explained:
  48. # /^##/:
  49. # * save line in hold space
  50. # * purge line
  51. # * Loop:
  52. # * append newline + line to hold space
  53. # * go to next line
  54. # * if line starts with doc comment, strip comment character off and loop
  55. # * remove target prerequisites
  56. # * append hold space (+ newline) to line
  57. # * replace newline plus comments by `---`
  58. # * print line
  59. # Separate expressions are necessary because labels cannot be delimited by
  60. # semicolon; see <http://stackoverflow.com/a/11799865/1968>
  61. .PHONY: help
  62. help:
  63. @echo "$$(tput bold)Available rules:$$(tput sgr0)"
  64. @echo
  65. @sed -n -e "/^## / Missing" $Missing \
  66. | LC_ALL='C' sort --ignore-case \
  67. | awk -F '---' \
  68. -v ncol=$$(tput cols) \
  69. -v indent=19 \
  70. -v col_on="$$(tput setaf 6)" \
  71. -v col_off="$$(tput sgr0)" \
  72. 'Missing \
  73. printf "%s ", words[i]; \
  74. } \
  75. printf "\n"; \
  76. }' \
  77. | more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars')